summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-09-14 05:09:48 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-09-14 05:09:48 (GMT)
commit4aa74c429cabef6aaf91b2b0d4c2163778b1249d (patch)
tree2615bf5ed21c6b39c4b6c94f1fc536e1f266e890 /Lib
parent134192630a28d6ae6c2a256f95a44a2dd3c65388 (diff)
downloadcpython-4aa74c429cabef6aaf91b2b0d4c2163778b1249d.zip
cpython-4aa74c429cabef6aaf91b2b0d4c2163778b1249d.tar.gz
cpython-4aa74c429cabef6aaf91b2b0d4c2163778b1249d.tar.bz2
Issue #28131: Fix a regression in zipimport's compile_source()
zipimport should use the same optimization level as the interpreter.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_zipimport.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 2bb7230..d5b3b22 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