New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.0.1 crashes in unicode path #49523
Comments
In unicode path Python 3.0.1 crashes when importing compiled module. Detailed Situation:
OS: win2000
current pathname contains Japanese characters.
./a.py contains only a statement "import b".
./b.py is empty.
> python a.py
(nothing is happen but b.pyc is created)
> python a.py
Traceback (most recent call last):
File "a.py", line 1, in <module>
import b
UnicodeDecodeError: 'utf8' codec can't decode byte 0x82 in position 3:
unexpected code byte |
Quick observation. This bug was introduces in r68363. import.c(994)
newname = PyUnicode_FromString(pathname); pathname is mbcs on windows, but PyUnicode_FromString assumes it as UTF8. |
Here is a patch. |
Gasp. Sorry for the bug. |
I'm not sure. Even my patch might not be correct anyway. On my VC6 Debugger, But its caller load_source_module is calling if (fstat(fileno(fp), &st) != 0) {
PyErr_Format(PyExc_RuntimeError,
"unable to get file status from '%s'",
pathname);
return NULL;
} I've looked into PyErr_Format code, it seems %s assumes utf-8. Anway, |
I tracked down, and I found this mbcs path is set in Python/import.c(1394) if (PyUnicode_Check(v)) {
v = PyUnicode_AsEncodedString(v,
Py_FileSystemDefaultEncoding, NULL);
if (v == NULL)
return NULL;
} And this was introduced in r64126 to fix segfault mentioned in |
I hope revised patch will fix this too. There seems to be no function to bpo-3080 is big issue, so this is minimal solution for this issue. I |
I cannot say anything except that the patch looks ok. If it doesn't make |
Thanks, fixed in r70157(py3k) and r70158(release30-maint) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: