mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
Issue #25758: Prevents zipimport from unnecessarily encoding a filename (patch by Eryk Sun)
This commit is contained in:
commit
ff70fc2206
3 changed files with 8 additions and 11 deletions
|
@ -615,7 +615,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
|
||||||
z.writestr(zinfo, test_src)
|
z.writestr(zinfo, test_src)
|
||||||
z.close()
|
z.close()
|
||||||
try:
|
try:
|
||||||
zipimport.zipimporter(filename)
|
zipimport.zipimporter(filename).load_module(TESTMOD)
|
||||||
finally:
|
finally:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.6.0 beta 1
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #25758: Prevents zipimport from unnecessarily encoding a filename
|
||||||
|
(patch by Eryk Sun)
|
||||||
|
|
||||||
- Issue #25856: The __module__ attribute of extension classes and functions
|
- Issue #25856: The __module__ attribute of extension classes and functions
|
||||||
now is interned. This leads to more compact pickle data with protocol 4.
|
now is interned. This leads to more compact pickle data with protocol 4.
|
||||||
|
|
||||||
|
|
|
@ -1362,22 +1362,16 @@ normalize_line_endings(PyObject *source)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
compile_source(PyObject *pathname, PyObject *source)
|
compile_source(PyObject *pathname, PyObject *source)
|
||||||
{
|
{
|
||||||
PyObject *code, *fixed_source, *pathbytes;
|
PyObject *code, *fixed_source;
|
||||||
|
|
||||||
pathbytes = PyUnicode_EncodeFSDefault(pathname);
|
|
||||||
if (pathbytes == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
fixed_source = normalize_line_endings(source);
|
fixed_source = normalize_line_endings(source);
|
||||||
if (fixed_source == NULL) {
|
if (fixed_source == NULL) {
|
||||||
Py_DECREF(pathbytes);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = Py_CompileString(PyBytes_AsString(fixed_source),
|
code = Py_CompileStringObject(PyBytes_AsString(fixed_source),
|
||||||
PyBytes_AsString(pathbytes),
|
pathname, Py_file_input, NULL, 1);
|
||||||
Py_file_input);
|
|
||||||
Py_DECREF(pathbytes);
|
|
||||||
Py_DECREF(fixed_source);
|
Py_DECREF(fixed_source);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue