From e1b4cbc422efc2cc6c5bbbf26645dbb5c001cb49 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 14 May 2013 22:31:26 -0500 Subject: when arguments are cells clear the locals slot (backport of #17927) --- Python/ceval.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Python') diff --git a/Python/ceval.c b/Python/ceval.c index f42784141d..e59c39ddd7 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3403,10 +3403,14 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, int arg; /* Possibly account for the cell variable being an argument. */ if (co->co_cell2arg != NULL && - (arg = co->co_cell2arg[i]) != CO_CELL_NOT_AN_ARG) + (arg = co->co_cell2arg[i]) != CO_CELL_NOT_AN_ARG) { c = PyCell_New(GETLOCAL(arg)); - else + /* Clear the local copy. */ + SETLOCAL(arg, NULL); + } + else { c = PyCell_New(NULL); + } if (c == NULL) goto fail; SETLOCAL(co->co_nlocals + i, c); -- cgit v1.2.1