8000 fix test_positional_only_arg · python/cpython@f38de20 · GitHub
[go: up one dir, main page]

Skip to content

Commit f38de20

Browse files
committed
fix test_positional_only_arg
1 parent ed16167 commit f38de20

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/test/test_positional_only_arg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dis
44
import pickle
5+
import types
56
import unittest
67

78
from test.support import check_syntax_error
@@ -440,7 +441,9 @@ def f(x: not (int is int), /): ...
440441
# without constant folding we end up with
441442
# COMPARE_OP(is), IS_OP (0)
442443
# with constant folding we should expect a IS_OP (1)
443-
codes = [(i.opname, i.argval) for i in dis.get_instructions(g)]
444+
code_obj = next(const for const in g.__code__.co_consts
445+
if isinstance(const, types.CodeType) and "annotations" in const.co_name)
446+
codes = [(i.opname, i.argval) for i in dis.get_instructions(code_obj)]
444447
self.assertNotIn(('UNARY_NOT', None), codes)
445448
self.assertIn(('IS_OP', 1), codes)
446449

0 commit comments

Comments
 (0)
0