changeset: 103508:663a62bcf9c9 branch: 3.5 parent: 103506:f1bf0abcca0c user: Steve Dower date: Fri Sep 09 17:27:33 2016 -0700 files: Lib/test/test_zipimport.py Misc/NEWS Modules/zipimport.c description: Issue #25758: Prevents zipimport from unnecessarily encoding a filename (patch by Eryk Sun) diff -r f1bf0abcca0c -r 663a62bcf9c9 Lib/test/test_zipimport.py --- a/Lib/test/test_zipimport.py Fri Sep 09 20:04:23 2016 -0400 +++ b/Lib/test/test_zipimport.py Fri Sep 09 17:27:33 2016 -0700 @@ -596,7 +596,7 @@ z.writestr(zinfo, test_src) z.close() try: - zipimport.zipimporter(filename) + zipimport.zipimporter(filename).load_module(TESTMOD) finally: os.remove(filename) diff -r f1bf0abcca0c -r 663a62bcf9c9 Misc/NEWS --- a/Misc/NEWS Fri Sep 09 20:04:23 2016 -0400 +++ b/Misc/NEWS Fri Sep 09 17:27:33 2016 -0700 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #25758: Prevents zipimport from unnecessarily encoding a filename + (patch by Eryk Sun) + - Issue #27812: Properly clear out a generator's frame's backreference to the generator to prevent crashes in frame.clear(). diff -r f1bf0abcca0c -r 663a62bcf9c9 Modules/zipimport.c --- a/Modules/zipimport.c Fri Sep 09 20:04:23 2016 -0400 +++ b/Modules/zipimport.c Fri Sep 09 17:27:33 2016 -0700 @@ -1362,22 +1362,16 @@ static PyObject * compile_source(PyObject *pathname, PyObject *source) { - PyObject *code, *fixed_source, *pathbytes; - - pathbytes = PyUnicode_EncodeFSDefault(pathname); - if (pathbytes == NULL) - return NULL; + PyObject *code, *fixed_source; fixed_source = normalize_line_endings(source); if (fixed_source == NULL) { - Py_DECREF(pathbytes); return NULL; } - code = Py_CompileString(PyBytes_AsString(fixed_source), - PyBytes_AsString(pathbytes), - Py_file_input); - Py_DECREF(pathbytes); + code = Py_CompileStringObject(PyBytes_AsString(fixed_source), + pathname, Py_file_input, NULL, 1); + Py_DECREF(fixed_source); return code; }