gh-119180: PEP 649 compiler changes (#119361)

This commit is contained in:
Jelle Zijlstra 2024-06-11 07:06:49 -06:00 committed by GitHub
parent 02c1dfff07
commit 9b8611eeea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 610 additions and 329 deletions

View file

@ -2,6 +2,7 @@
import dis
import pickle
import types
import unittest
from test.support import check_syntax_error
@ -440,7 +441,9 @@ class PositionalOnlyTestCase(unittest.TestCase):
# without constant folding we end up with
# COMPARE_OP(is), IS_OP (0)
# with constant folding we should expect a IS_OP (1)
codes = [(i.opname, i.argval) for i in dis.get_instructions(g)]
code_obj = next(const for const in g.__code__.co_consts
if isinstance(const, types.CodeType) and const.co_name == "__annotate__")
codes = [(i.opname, i.argval) for i in dis.get_instructions(code_obj)]
self.assertNotIn(('UNARY_NOT', None), codes)
self.assertIn(('IS_OP', 1), codes)