[3.14] gh-132775: Expand the Capability of Interpreter.call() (gh-134933)

It now supports most callables, full args, and return values.

(cherry picked from commit 52deabe, AKA gh-133484)

Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
This commit is contained in:
Miss Islington (bot) 2025-05-30 20:28:35 +02:00 committed by GitHub
parent 69536093de
commit d45d053267
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 32773 additions and 31776 deletions

View file

@ -701,6 +701,26 @@ def test_local_kinds(self):
'checks': CO_FAST_LOCAL,
'res': CO_FAST_LOCAL,
},
defs.spam_full_args: {
'a': POSONLY,
'b': POSONLY,
'c': POSORKW,
'd': POSORKW,
'e': KWONLY,
'f': KWONLY,
'args': VARARGS,
'kwargs': VARKWARGS,
},
defs.spam_full_args_with_defaults: {
'a': POSONLY,
'b': POSONLY,
'c': POSORKW,
'd': POSORKW,
'e': KWONLY,
'f': KWONLY,
'args': VARARGS,
'kwargs': VARKWARGS,
},
defs.spam_args_attrs_and_builtins: {
'a': POSONLY,
'b': POSONLY,
@ -714,6 +734,7 @@ def test_local_kinds(self):
defs.spam_returns_arg: {
'x': POSORKW,
},
defs.spam_raises: {},
defs.spam_with_inner_not_closure: {
'eggs': CO_FAST_LOCAL,
},
@ -934,6 +955,20 @@ def new_var_counts(*,
purelocals=5,
globalvars=6,
),
defs.spam_full_args: new_var_counts(
posonly=2,
posorkw=2,
kwonly=2,
varargs=1,
varkwargs=1,
),
defs.spam_full_args_with_defaults: new_var_counts(
posonly=2,
posorkw=2,
kwonly=2,
varargs=1,
varkwargs=1,
),
defs.spam_args_attrs_and_builtins: new_var_counts(
posonly=2,
posorkw=2,
@ -945,6 +980,9 @@ def new_var_counts(*,
defs.spam_returns_arg: new_var_counts(
posorkw=1,
),
defs.spam_raises: new_var_counts(
globalvars=1,
),
defs.spam_with_inner_not_closure: new_var_counts(
purelocals=1,
),
@ -1097,10 +1135,16 @@ def new_var_counts(*,
def test_stateless(self):
self.maxDiff = None
STATELESS_FUNCTIONS = [
*defs.STATELESS_FUNCTIONS,
# stateless with defaults
defs.spam_full_args_with_defaults,
]
for func in defs.STATELESS_CODE:
with self.subTest((func, '(code)')):
_testinternalcapi.verify_stateless_code(func.__code__)
for func in defs.STATELESS_FUNCTIONS:
for func in STATELESS_FUNCTIONS:
with self.subTest((func, '(func)')):
_testinternalcapi.verify_stateless_code(func)
@ -1110,7 +1154,7 @@ def test_stateless(self):
with self.assertRaises(Exception):
_testinternalcapi.verify_stateless_code(func.__code__)
if func not in defs.STATELESS_FUNCTIONS:
if func not in STATELESS_FUNCTIONS:
with self.subTest((func, '(func)')):
with self.assertRaises(Exception):
_testinternalcapi.verify_stateless_code(func)