cpython: 7bec326972f5 (original) (raw)
Mercurial > cpython
changeset 103776:7bec326972f5 3.5
Issue #28131: Fix a regression in zipimport's compile_source() zipimport should use the same optimization level as the interpreter. [#28131]
Berker Peksag berker.peksag@gmail.com | |
---|---|
date | Wed, 14 Sep 2016 08:09:48 +0300 |
parents | 36550e4f9b4c |
children | 7a6c0c4e6072 2fb148cd95a2 |
files | Lib/test/test_zipimport.py Misc/NEWS Modules/zipimport.c |
diffstat | 3 files changed, 17 insertions(+), 1 deletions(-)[+] [-] Lib/test/test_zipimport.py 13 Misc/NEWS 3 Modules/zipimport.c 2 |
line wrap: on
line diff
--- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -513,6 +513,19 @@ class UncompressedZipImportTestCase(Impo "some.data": (NOW, "some data")} self.doTest(pyc_ext, files, TESTMOD)
- def testDefaultOptimizationLevel(self):
# zipimport should use the default optimization level (#28131)[](#l1.8)
src = """if 1: # indent hack[](#l1.9)
def test(val):[](#l1.10)
assert(val)[](#l1.11)
return val\n"""[](#l1.12)
files = {TESTMOD + '.py': (NOW, src)}[](#l1.13)
self.makeZip(files)[](#l1.14)
sys.path.insert(0, TEMP_ZIP)[](#l1.15)
mod = importlib.import_module(TESTMOD)[](#l1.16)
self.assertEqual(mod.test(1), 1)[](#l1.17)
self.assertRaises(AssertionError, mod.test, False)[](#l1.18)
+ def testImport_WithStuff(self): # try importing from a zipfile which contains additional # stuff at the beginning of the file
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Release date: TBA Core and Builtins ----------------- +- Issue #28131: Fix a regression in zipimport's compile_source(). zipimport
- Issue #25221: Fix corrupted result from PyLong_FromLong(0) when Python is compiled with NSMALLPOSINTS = 0.
--- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -1370,7 +1370,7 @@ compile_source(PyObject *pathname, PyObj } code = Py_CompileStringObject(PyBytes_AsString(fixed_source),
pathname, Py_file_input, NULL, 1);[](#l3.7)
pathname, Py_file_input, NULL, -1);[](#l3.8)