summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-08-02 08:30:07 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-08-02 08:30:07 (GMT)
commit66bd23322567a9ef0ad7bbe2436fef73b18bc9db (patch)
tree42b92af0e05cd7778f47a2e905dc559eaf50caca /Python
parent32083f64a71c4ac80830231479914e40cbd8488b (diff)
downloadcpython-66bd23322567a9ef0ad7bbe2436fef73b18bc9db.zip
cpython-66bd23322567a9ef0ad7bbe2436fef73b18bc9db.tar.gz
cpython-66bd23322567a9ef0ad7bbe2436fef73b18bc9db.tar.bz2
Completed the patch for Bug #215126.
* Fixes an incorrect variable in a PyDict_CheckExact. * Allow general mapping locals arguments for the execfile() function and exec statement. * Add tests.
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c8
-rw-r--r--Python/ceval.c6
2 files changed, 9 insertions, 5 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 4143681..b76f373 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -539,11 +539,15 @@ builtin_execfile(PyObject *self, PyObject *args)
PyCompilerFlags cf;
int exists;
- if (!PyArg_ParseTuple(args, "s|O!O!:execfile",
+ if (!PyArg_ParseTuple(args, "s|O!O:execfile",
&filename,
&PyDict_Type, &globals,
- &PyDict_Type, &locals))
+ &locals))
return NULL;
+ if (locals != Py_None && !PyMapping_Check(locals)) {
+ PyErr_SetString(PyExc_TypeError, "locals must be a mapping");
+ return NULL;
+ }
if (globals == Py_None) {
globals = PyEval_GetGlobals();
if (locals == Py_None)
diff --git a/Python/ceval.c b/Python/ceval.c
index 152b942..3a462af 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1643,7 +1643,7 @@ PyEval_EvalFrame(PyFrameObject *f)
w = GETITEM(names, oparg);
v = POP();
if ((x = f->f_locals) != NULL) {
- if (PyDict_CheckExact(v))
+ if (PyDict_CheckExact(x))
err = PyDict_SetItem(x, w, v);
else
err = PyObject_SetItem(x, w, v);
@@ -4116,9 +4116,9 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
"exec: arg 2 must be a dictionary or None");
return -1;
}
- if (!PyDict_Check(locals)) {
+ if (!PyMapping_Check(locals)) {
PyErr_SetString(PyExc_TypeError,
- "exec: arg 3 must be a dictionary or None");
+ "exec: arg 3 must be a mapping or None");
return -1;
}
if (PyDict_GetItemString(globals, "__builtins__") == NULL)