https://github.com/python/cpython/commit/64dcbb0c31adb068570725003fd6d2ddd8ee1507
commit: 64dcbb0c31adb068570725003fd6d2ddd8ee1507
branch: 3.13
author: Neil Schemenauer <nas-git...@arctrix.com>
committer: nascheme <nas-git...@arctrix.com>
date: 2025-04-29T03:33:13Z
summary:

[3.13] gh-133122: Fix for test_type_lookup_mro_reference. (gh-133127)

Change the unit test case to use `getattr()` so that we avoid the
bytecode specializer optimizing the access.  The specializer will call
the `__eq__` method before the unit test expects, causing it to fail.

In the 3.14 branch (gh-128164) the test is changed in a different way
to avoid the same issue.

files:
M Lib/test/test_descr.py

diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index f5f8931a046b81..ebea459f1ac6b7 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -5177,10 +5177,15 @@ class Base2(object):
 
         with self.assertWarnsRegex(RuntimeWarning, 'X'):
             X = type('X', (Base,), {MyKey(): 5})
+
+        # Note that the access below uses getattr() rather than normally
+        # accessing the attribute.  That is done to avoid the bytecode
+        # specializer activating on repeated runs of the test.
+
         # mykey is read from Base
-        self.assertEqual(X.mykey, 'from Base')
+        self.assertEqual(getattr(X, 'mykey'), 'from Base')
         # mykey2 is read from Base2 because MyKey.__eq__ has set __bases__
-        self.assertEqual(X.mykey2, 'from Base2')
+        self.assertEqual(getattr(X, 'mykey2'), 'from Base2')
 
 
 class PicklingTests(unittest.TestCase):

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to