-
-
Notifications
You must be signed in to change notification settings - Fork 35k
bpo-32381: .pyc files with non-ASCII paths cannot be reopened on Windows #14699
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ``.pyc`` files with non-ASCII paths can now be reopened on Windows. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1365,7 +1365,7 @@ _Py_wfopen(const wchar_t *path, const wchar_t *mode) | |
| return f; | ||
| } | ||
|
|
||
| /* Wrapper to fopen(). | ||
| /* Open a file. | ||
|
|
||
| The file descriptor is created non-inheritable. | ||
|
|
||
|
|
@@ -1377,14 +1377,13 @@ _Py_fopen(const char *pathname, const char *mode) | |
| return NULL; | ||
| } | ||
|
|
||
| FILE *f = fopen(pathname, mode); | ||
| if (f == NULL) | ||
| return NULL; | ||
| if (make_non_inheritable(fileno(f)) < 0) { | ||
| fclose(f); | ||
| PyObject *path = PyUnicode_DecodeFSDefault(pathname); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change should be conditionally defined just for Windows. In the Unix world a path is just a sequence of bytes, with only ASCII slash and null reserved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed with @eryksun. Performing the change across all OS's wouldn't be necessary, since this is a windows specific issue.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, @eryksun, for the comment. One issue is the fact that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a problem that (Another issue is with |
||
| if (path == NULL) { | ||
| return NULL; | ||
| } | ||
| return f; | ||
| FILE *ret = _Py_fopen_obj(path, mode); | ||
| Py_DECREF(path); | ||
| return ret; | ||
| } | ||
|
|
||
| /* Open a file. Call _wfopen() on Windows, or encode the path to the filesystem | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of
test_issue32381, I would recommend renaming the method to something more descriptive of the issue itself, such astest_windows_non_ascii_path.