Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix the tests.
  • Loading branch information
ericsnowcurrently committed May 21, 2025
commit 51afd9b973df09e017d3f34a0227b73182bbce9b
3 changes: 2 additions & 1 deletion Lib/test/test__interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ def test_closure(self):
def script():
assert spam

with self.assertRaises(ValueError):
with self.assertRaises(TypeError):
_interpreters.run_func(self.id, script)

# XXX This hasn't been fixed yet.
Expand All @@ -1065,6 +1065,7 @@ def script():
with self.assertRaises(ValueError):
_interpreters.run_func(self.id, script)

@unittest.skip("we're not quite there yet")
def test_args(self):
with self.subTest('args'):
def script(a, b=0):
Expand Down
9 changes: 6 additions & 3 deletions Modules/_interpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,11 +972,14 @@ convert_code_arg(PyThreadState *tstate,
PyObject *cause;
PyCodeObject *code = NULL;
if (PyFunction_Check(arg)) {
if (_PyFunction_VerifyStateless(tstate, arg) < 0) {
// For now we allow globals, so we can't use
// _PyFunction_VerifyStateless().
PyObject *codeobj = PyFunction_GetCode(arg);
if (_PyCode_VerifyStateless(
tstate, (PyCodeObject *)codeobj, NULL, NULL, NULL) < 0) {
goto chained;
}
code = (PyCodeObject *)PyFunction_GetCode(arg);
Py_INCREF(code);
code = (PyCodeObject *)Py_NewRef(codeobj);
}
else if (PyCode_Check(arg)) {
if (_PyCode_VerifyStateless(
Expand Down