@@ -2501,54 +2501,21 @@ def testfunc(n):
25012501 # For now... until we constant propagate it away.
25022502 self .assertIn ("_BINARY_OP" , uops )
25032503
2504- def test_strip_reference_information_through_str (self ):
2505- # This test needs to be in another script due to Python's
2506- # string interning details.
2507- script_helper .assert_python_ok ('-c' , textwrap .dedent ("""
2508- import _testinternalcapi
2509- import _opcode
2510-
2511- def get_first_executor(func):
2512- code = func.__code__
2513- co_code = code.co_code
2514- for i in range(0, len(co_code), 2):
2515- try:
2516- return _opcode.get_executor(code, i)
2517- except ValueError:
2518- pass
2519- return None
2504+ def test_reference_tracking_across_call_doesnt_crash (self ):
25202505
2521- def iter_opnames(ex):
2522- for item in ex:
2523- yield item[0]
2506+ def f1 ():
2507+ for _ in range (TIER2_THRESHOLD + 1 ):
2508+ # Choose a value that won't occur elsewhere to avoid sharing
2509+ str ("value that won't occur elsewhere to avoid sharing" )
25242510
2525- def get_opnames(ex):
2526- return list(iter_opnames(ex))
2511+ f1 ()
25272512
2528- def testfunc(n):
2529- for _ in range(n):
2530- str("abcde")
2531-
2532-
2533- testfunc(_testinternalcapi.TIER2_THRESHOLD)
2534- ex = get_first_executor(testfunc)
2535- assert ex is not None
2536- uops = get_opnames(ex)
2537- assert "_POP_TOP_NOP" not in uops
2538- """ ))
2539-
2540- def test_strip_reference_information_through_tuple (self ):
2541- def testfunc (n ):
2542- for _ in range (n ):
2543- tuple ((1 ,))
2544-
2545- testfunc (TIER2_THRESHOLD * 2 )
2546-
2547- ex = get_first_executor (testfunc )
2548- self .assertIsNotNone (ex )
2549- uops = get_opnames (ex )
2513+ def f2 ():
2514+ for _ in range (TIER2_THRESHOLD + 1 ):
2515+ # Choose a value that won't occur elsewhere to avoid sharing
2516+ tuple ((31 , - 17 , 25 , "won't occur elsewhere" ))
25502517
2551- self . assertNotIn ( "_POP_TOP_NOP" , uops )
2518+ f2 ( )
25522519
25532520
25542521def global_identity (x ):
0 commit comments