#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
DL_IMPORT(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
- PyObject *, PyObject *,
- PyObject *);
+ PyObject *, PyObject *);
/* The rest of the interface is specific for frame objects */
c, /*code*/
tstate->frame->f_globals, /*globals*/
NULL /*locals*/
-#if PYTHON_API_VERSION >= 1010
- ,NULL /*closure*/
-#endif
);
if (f == NULL)
return NULL;
static int
cell_clear(PyCellObject *op)
{
+ Py_XDECREF(op->ob_ref);
op->ob_ref = NULL;
return 0;
}
static void
frame_dealloc(PyFrameObject *f)
{
- int i;
+ int i, slots;
PyObject **fastlocals;
Py_TRASHCAN_SAFE_BEGIN(f)
/* Kill all local variables */
+ slots = f->f_nlocals + f->f_ncells + f->f_nfreevars;
fastlocals = f->f_localsplus;
- for (i = f->f_nlocals; --i >= 0; ++fastlocals) {
+ for (i = slots; --i >= 0; ++fastlocals) {
Py_XDECREF(*fastlocals);
}
PyFrameObject *
PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals,
- PyObject *locals, PyObject *closure)
+ PyObject *locals)
{
PyFrameObject *back = tstate->frame;
static PyObject *builtin_object;
f = PyFrame_New(tstate, /*back*/
co, /*code*/
- globals, locals, closure);
+ globals, locals);
if (f == NULL)
return NULL;
}
if (f->f_nfreevars) {
int i;
- for (i = 0; i < f->f_nfreevars; ++i)
- freevars[f->f_ncells + i] = PyTuple_GET_ITEM(closure, i);
+ for (i = 0; i < f->f_nfreevars; ++i) {
+ PyObject *o = PyTuple_GET_ITEM(closure, i);
+ Py_INCREF(o);
+ freevars[f->f_ncells + i] = o;
+ }
}
if (tstate->sys_tracefunc != NULL) {
err = -1;
break;
}
- Py_INCREF(w);
PUSH(w);
break;
w = POP();
x = freevars[oparg];
PyCell_Set(x, w);
+ Py_DECREF(w);
continue;
case BUILD_TUPLE: