mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
451e99b393
commit
8a9583ec5c
3 changed files with 26 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue