summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_opcache.py
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2023-04-25 17:45:51 (GMT)
committerGitHub <noreply@github.com>2023-04-25 17:45:51 (GMT)
commitef25febcf2ede92a03c5ea00a13e167e0b5cb274 (patch)
tree6ce38cd3aa3d653d931df5250b02b5cb6b46bb69 /Lib/test/test_opcache.py
parentcef542ca572fdd402ff0e10093a0c1b459e5dcd6 (diff)
downloadcpython-ef25febcf2ede92a03c5ea00a13e167e0b5cb274.zip
cpython-ef25febcf2ede92a03c5ea00a13e167e0b5cb274.tar.gz
cpython-ef25febcf2ede92a03c5ea00a13e167e0b5cb274.tar.bz2
gh-87729: specialize LOAD_SUPER_ATTR_METHOD (#103809)
Diffstat (limited to 'Lib/test/test_opcache.py')
-rw-r--r--Lib/test/test_opcache.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_opcache.py b/Lib/test/test_opcache.py
index e39b726..57fed5d 100644
--- a/Lib/test/test_opcache.py
+++ b/Lib/test/test_opcache.py
@@ -1,6 +1,29 @@
import unittest
+class TestLoadSuperAttrCache(unittest.TestCase):
+ def test_descriptor_not_double_executed_on_spec_fail(self):
+ calls = []
+ class Descriptor:
+ def __get__(self, instance, owner):
+ calls.append((instance, owner))
+ return lambda: 1
+
+ class C:
+ d = Descriptor()
+
+ class D(C):
+ def f(self):
+ return super().d()
+
+ d = D()
+
+ self.assertEqual(d.f(), 1) # warmup
+ calls.clear()
+ self.assertEqual(d.f(), 1) # try to specialize
+ self.assertEqual(calls, [(d, D)])
+
+
class TestLoadAttrCache(unittest.TestCase):
def test_descriptor_added_after_optimization(self):
class Descriptor: