summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compile.py
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2021-02-10 00:20:42 (GMT)
committerGitHub <noreply@github.com>2021-02-10 00:20:42 (GMT)
commitbdb941be423bde8b02a5695ccf51c303d6204bed (patch)
treee84e49eca1b557ec85efa21c815260182ea8fd7a /Lib/test/test_compile.py
parentdbb228189b4eb7ab41f326eb79dae669b2c81177 (diff)
downloadcpython-bdb941be423bde8b02a5695ccf51c303d6204bed.zip
cpython-bdb941be423bde8b02a5695ccf51c303d6204bed.tar.gz
cpython-bdb941be423bde8b02a5695ccf51c303d6204bed.tar.bz2
bpo-42217: compiler: merge same co_code and co_linetable objects (GH-23056)
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r--Lib/test/test_compile.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 3e826b9..1f12524 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -632,6 +632,17 @@ if 1:
self.check_constant(f1, frozenset({0}))
self.assertTrue(f1(0))
+ # Merging equal co_linetable and co_code is not a strict requirement
+ # for the Python semantics, it's a more an implementation detail.
+ @support.cpython_only
+ def test_merge_code_attrs(self):
+ # See https://bugs.python.org/issue42217
+ f1 = lambda x: x.y.z
+ f2 = lambda a: a.b.c
+
+ self.assertIs(f1.__code__.co_linetable, f2.__code__.co_linetable)
+ self.assertIs(f1.__code__.co_code, f2.__code__.co_code)
+
# This is a regression test for a CPython specific peephole optimizer
# implementation bug present in a few releases. It's assertion verifies
# that peephole optimization was actually done though that isn't an