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
7 changes: 7 additions & 0 deletions Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,13 @@ def four_freevars():
closure=my_closure)
self.assertEqual(result, 2520)

# should fail: closure isn't allowed
# when source is a string
self.assertRaises(TypeError,
exec,
"pass",
closure=my_closure)

# should fail: closure isn't allowed
# for functions without free vars
self.assertRaises(TypeError,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``exec()`` called with a string ``source`` argument and non-``None`` ``closure`` argument no longer fails with a segmentation
fault. Patch by Bartosz Sławecki.
1 change: 1 addition & 0 deletions Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
if (closure != NULL) {
PyErr_SetString(PyExc_TypeError,
"closure can only be used when source is a code object");
goto error;
}
PyObject *source_copy;
const char *str;
Expand Down
Loading