mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
try to use the same str object for all code filenames when compiling or unmarshalling (#12190)
This should reduce memory usage.
This commit is contained in:
parent
d408503b2c
commit
43b068648e
5 changed files with 57 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
|||
import unittest
|
||||
import sys
|
||||
import _ast
|
||||
import types
|
||||
from test import support
|
||||
|
||||
class TestSpecifics(unittest.TestCase):
|
||||
|
@ -433,6 +434,14 @@ if 1:
|
|||
ast.body = [_ast.BoolOp()]
|
||||
self.assertRaises(TypeError, compile, ast, '<ast>', 'exec')
|
||||
|
||||
@support.cpython_only
|
||||
def test_same_filename_used(self):
|
||||
s = """def f(): pass\ndef g(): pass"""
|
||||
c = compile(s, "myfile", "exec")
|
||||
for obj in c.co_consts:
|
||||
if isinstance(obj, types.CodeType):
|
||||
self.assertIs(obj.co_filename, c.co_filename)
|
||||
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(TestSpecifics)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue