gh-91625: Don't ignore extended args of adaptive opcodes (GH-91626)

This commit is contained in:
Dennis Sweeney 2022-04-17 14:04:29 -04:00 committed by GitHub
parent 7659681556
commit cec5d858f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 18 deletions

View file

@ -133,6 +133,18 @@ def test_eval_gives_lambda_custom_globals(self):
self.assertEqual(foo(), 7)
def test_load_global_specialization_failure_keeps_oparg(self):
# https://github.com/python/cpython/issues/91625
class MyGlobals(dict):
def __missing__(self, key):
return int(key.removeprefix("_number_"))
code = "lambda: " + "+".join(f"_number_{i}" for i in range(1000))
sum_1000 = eval(code, MyGlobals())
expected = sum(range(1000))
# Warm up the the function for quickening (PEP 659)
for _ in range(30):
self.assertEqual(sum_1000(), expected)
if __name__ == "__main__":
unittest.main()