]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF patch 103596 by Nick Mathewson: rause UnboundLocalError for
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 5 Feb 2001 17:23:16 +0000 (17:23 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 5 Feb 2001 17:23:16 +0000 (17:23 +0000)
uninitialized free variables

Python/ceval.c

index 264ba30a759f37e2a2488aaa2a965ea2c4ec0b7d..9d6549572f5600272ec3060a369a74956d72c993 100644 (file)
@@ -1646,6 +1646,22 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
                case LOAD_DEREF:
                        x = freevars[oparg];
                        w = PyCell_Get(x);
+                       if (w == NULL) {
+                               if (oparg < f->f_ncells)
+                                       v = PyTuple_GetItem(co->co_cellvars,
+                                                              oparg);
+                               else
+                                      v = PyTuple_GetItem(
+                                                     co->co_freevars,
+                                                     oparg - f->f_ncells);
+
+                               format_exc_check_arg(
+                                       PyExc_UnboundLocalError,
+                                       UNBOUNDLOCAL_ERROR_MSG,
+                                       v);
+                               err = -1;
+                               break;
+                       }
                        Py_INCREF(w);
                        PUSH(w);
                        break;