bpo-42217: compiler: merge same co_code and co_linetable objects (GH-23056)

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 @@ 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