From 513ffe81122274973d2adeff13345589d4313d47 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 6 Jul 2004 13:44:41 +0000 Subject: * Fix missing return after error message is set. * Add a test case that would have caught it. --- Lib/test/test_builtin.py | 1 + Python/bltinmodule.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 8fea0ca..fdbbdfc 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -281,6 +281,7 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(eval('dir()', g, m), list('xyz')) self.assertEqual(eval('globals()', g, m), g) self.assertEqual(eval('locals()', g, m), m) + self.assertRaises(TypeError, eval, 'a', m) # Verify that dict subclasses work as well class D(dict): diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index f4f8b7a..3604601 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -459,12 +459,13 @@ builtin_eval(PyObject *self, PyObject *args) return NULL; if (locals != Py_None && !PyMapping_Check(locals)) { PyErr_SetString(PyExc_TypeError, "locals must be a mapping"); - return NULL; + return NULL; } if (globals != Py_None && !PyDict_Check(globals)) { PyErr_SetString(PyExc_TypeError, PyMapping_Check(globals) ? "globals must be a real dict; try eval(expr, {}, mapping)" : "globals must be a dict"); + return NULL; } if (globals == Py_None) { globals = PyEval_GetGlobals(); -- cgit v0.12