diff options
author | Inada Naoki <songofacandy@gmail.com> | 2021-02-10 09:20:42 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-10 09:20:42 +0900 |
commit | bdb941be423bde8b02a5695ccf51c303d6204bed (patch) | |
tree | e84e49eca1b557ec85efa21c815260182ea8fd7a /Lib | |
parent | bpo-43163: Handle unclosed parentheses in codeop (GH-24483) (diff) | |
download | cpython-bdb941be423bde8b02a5695ccf51c303d6204bed.tar.gz cpython-bdb941be423bde8b02a5695ccf51c303d6204bed.tar.bz2 cpython-bdb941be423bde8b02a5695ccf51c303d6204bed.zip |
bpo-42217: compiler: merge same co_code and co_linetable objects (GH-23056)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_compile.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 3e826b9accf..1f125242e15 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 |