mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #28131: Fix a regression in zipimport's compile_source()
zipimport should use the same optimization level as the interpreter.
This commit is contained in:
parent
134192630a
commit
4aa74c429c
3 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue