From bdb941be423bde8b02a5695ccf51c303d6204bed Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 10 Feb 2021 09:20:42 +0900 Subject: bpo-42217: compiler: merge same co_code and co_linetable objects (GH-23056) --- Lib/test/test_compile.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Lib') 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 @@ def check_same_constant(const): 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 -- cgit v1.2.3-65-gdbad