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

@ -1961,6 +1961,20 @@ order (MRO) for bases """
del a[0:10]
self.assertEqual(a.delitem, (slice(0, 10)))
def test_load_attr_extended_arg(self):
# https://github.com/python/cpython/issues/91625
class Numbers:
def __getattr__(self, attr):
return int(attr.lstrip("_"))
attrs = ", ".join(f"Z._{n:03d}" for n in range(280))
code = f"def number_attrs(Z):\n return [ {attrs} ]"
ns = {}
exec(code, ns)
number_attrs = ns["number_attrs"]
# Warm up the the function for quickening (PEP 659)
for _ in range(30):
self.assertEqual(number_attrs(Numbers()), list(range(280)))
def test_methods(self):
# Testing methods...
class C(object):
@ -4435,8 +4449,8 @@ order (MRO) for bases """
raise RuntimeError(f"Premature access to sys.stdout.{attr}")
with redirect_stdout(StdoutGuard()):
with self.assertRaises(RuntimeError):
print("Oops!")
with self.assertRaises(RuntimeError):
print("Oops!")
def test_vicious_descriptor_nonsense(self):
# Testing vicious_descriptor_nonsense...