diff Python/bltinmodule.c @ 86715:4ef4578db38a

Issue #18408: Add a new PyFrame_FastToLocalsWithError() function to handle exceptions when merging fast locals into f_locals of a frame. PyEval_GetLocals() now raises an exception and return NULL on failure.
author Victor Stinner <victor.stinner@gmail.com>
date Tue, 29 Oct 2013 01:19:37 +0100
parents 3055e61f1e66
children e5476ecb8b57
line wrap: on
line diff
--- a/Python/bltinmodule.c	Tue Oct 29 00:59:44 2013 +0100
+++ b/Python/bltinmodule.c	Tue Oct 29 01:19:37 2013 +0100
@@ -755,8 +755,11 @@
     }
     if (globals == Py_None) {
         globals = PyEval_GetGlobals();
-        if (locals == Py_None)
+        if (locals == Py_None) {
             locals = PyEval_GetLocals();
+            if (locals == NULL)
+                return NULL;
+        }
     }
     else if (locals == Py_None)
         locals = globals;
@@ -820,6 +823,8 @@
         globals = PyEval_GetGlobals();
         if (locals == Py_None) {
             locals = PyEval_GetLocals();
+            if (locals == NULL)
+                return NULL;
         }
         if (!globals || !locals) {
             PyErr_SetString(PyExc_SystemError,
@@ -1926,13 +1931,9 @@
         return NULL;
     if (v == NULL) {
         d = PyEval_GetLocals();
-        if (d == NULL) {
-            if (!PyErr_Occurred())
-                PyErr_SetString(PyExc_SystemError,
-                                "vars(): no locals!?");
-        }
-        else
-            Py_INCREF(d);
+        if (d == NULL)
+            return NULL;
+        Py_INCREF(d);
     }
     else {
         _Py_IDENTIFIER(__dict__);