diff options
| author | Carl Meyer <carl@oddbird.net> | 2023-04-25 17:45:51 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-25 17:45:51 (GMT) |
| commit | ef25febcf2ede92a03c5ea00a13e167e0b5cb274 (patch) | |
| tree | 6ce38cd3aa3d653d931df5250b02b5cb6b46bb69 /Lib/test/test_opcache.py | |
| parent | cef542ca572fdd402ff0e10093a0c1b459e5dcd6 (diff) | |
| download | cpython-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.py | 23 |
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: |
