Skip to content

Commit 5347018

Browse files
gh-108311: Fix test_store_attr_with_hint by disabling optimizer in decorator (#108312)
See #108311 (comment) --------- Co-authored-by: AlexWaygood <[email protected]>
1 parent 66b4d9c commit 5347018

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_opcache.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
import _testinternalcapi
99

1010

11+
def disabling_optimizer(func):
12+
def wrapper(*args, **kwargs):
13+
import _testinternalcapi
14+
old_opt = _testinternalcapi.get_optimizer()
15+
_testinternalcapi.set_optimizer(None)
16+
try:
17+
return func(*args, **kwargs)
18+
finally:
19+
_testinternalcapi.set_optimizer(old_opt)
20+
21+
return wrapper
22+
23+
1124
class TestLoadSuperAttrCache(unittest.TestCase):
1225
def test_descriptor_not_double_executed_on_spec_fail(self):
1326
calls = []
@@ -502,6 +515,7 @@ def assert_specialized(self, f, opname):
502515
opnames = {instruction.opname for instruction in instructions}
503516
self.assertIn(opname, opnames)
504517

518+
@disabling_optimizer
505519
def assert_races_do_not_crash(
506520
self, opname, get_items, read, write, *, check_items=False
507521
):

0 commit comments

Comments
 (0)