diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-09-14 08:09:48 +0300 |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-09-14 08:09:48 +0300 |
commit | 4aa74c429cabef6aaf91b2b0d4c2163778b1249d (patch) | |
tree | 2615bf5ed21c6b39c4b6c94f1fc536e1f266e890 | |
parent | 134192630a28d6ae6c2a256f95a44a2dd3c65388 (diff) | |
download | cpython-git-4aa74c429cabef6aaf91b2b0d4c2163778b1249d.tar.gz |
Issue #28131: Fix a regression in zipimport's compile_source()
zipimport should use the same optimization level as the interpreter.
-rw-r--r-- | Lib/test/test_zipimport.py | 13 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/zipimport.c | 2 |
3 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 2bb7230c26..d5b3b22ae1 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -513,6 +513,19 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): "some.data": (NOW, "some data")} self.doTest(pyc_ext, files, TESTMOD) + def testDefaultOptimizationLevel(self): + # zipimport should use the default optimization level (#28131) + src = """if 1: # indent hack + def test(val): + assert(val) + return val\n""" + files = {TESTMOD + '.py': (NOW, src)} + self.makeZip(files) + sys.path.insert(0, TEMP_ZIP) + mod = importlib.import_module(TESTMOD) + self.assertEqual(mod.test(1), 1) + self.assertRaises(AssertionError, mod.test, False) + def testImport_WithStuff(self): # try importing from a zipfile which contains additional # stuff at the beginning of the file @@ -10,6 +10,9 @@ Release date: TBA Core and Builtins ----------------- +- Issue #28131: Fix a regression in zipimport's compile_source(). zipimport + should use the same optimization level as the interpreter. + - Issue #25221: Fix corrupted result from PyLong_FromLong(0) when Python is compiled with NSMALLPOSINTS = 0. diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 92a82e6df2..7473a8fe87 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -1370,7 +1370,7 @@ compile_source(PyObject *pathname, PyObject *source) } code = Py_CompileStringObject(PyBytes_AsString(fixed_source), - pathname, Py_file_input, NULL, 1); + pathname, Py_file_input, NULL, -1); Py_DECREF(fixed_source); return code; |