aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-09-04 05:04:25 +0000
committerBrett Cannon <bcannon@gmail.com>2008-09-04 05:04:25 +0000
commit8a9583ec5c00384514fe9f5045866ad6ebd2be5a (patch)
treee360bd182c5c79d8dd3ca9147fce290b9efdda03 /Parser/tokenizer.c
parentInclude a pointer to the pybsddb website with the 'bsddb has been (diff)
downloadcpython-8a9583ec5c00384514fe9f5045866ad6ebd2be5a.tar.gz
cpython-8a9583ec5c00384514fe9f5045866ad6ebd2be5a.tar.bz2
cpython-8a9583ec5c00384514fe9f5045866ad6ebd2be5a.zip
PyTokenizer_FindEncoding() always failed because it set the tokenizer state
with only a file pointer when it called fp_setreadl() which expected a file path. Changed fp_setreadl() to use either a file path or file descriptor (derived from the file pointer) to fix the issue. Closes issue 3594. Reviewed by Antoine Pitrou and Benjamin Peterson.
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r--Parser/tokenizer.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index e2da3e5b6b0..e4cf8e4cc55 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -448,8 +448,12 @@ fp_setreadl(struct tok_state *tok, const char* enc)
if (io == NULL)
goto cleanup;
- stream = PyObject_CallMethod(io, "open", "ssis",
- tok->filename, "r", -1, enc);
+ if (tok->filename)
+ stream = PyObject_CallMethod(io, "open", "ssis",
+ tok->filename, "r", -1, enc);
+ else
+ stream = PyObject_CallMethod(io, "open", "isis",
+ fileno(tok->fp), "r", -1, enc);
if (stream == NULL)
goto cleanup;