Skip to content

Commit

Permalink
merge 3.3-slp (Stackless python#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselm Kruis committed Jan 5, 2017
2 parents ee7479d + 494f2c2 commit 28e4aa6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
10 changes: 7 additions & 3 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ slp_eval_frame_setup_with(PyFrameObject *f, int throwflag, PyObject *retval)
* SETUP_WITH operation.
* NOTE / XXX: see above.
*/
Py_XINCREF(f); /* fool the link optimizer */
Py_XINCREF(f); /* fool the link optimizer */
Py_XINCREF(retval); /* fool the link optimizer */
r = slp_eval_frame_value(f, throwflag, retval);
Py_XDECREF(retval);
Expand All @@ -1282,7 +1282,7 @@ slp_eval_frame_with_cleanup(PyFrameObject *f, int throwflag, PyObject *retval)
* NOTE / XXX: see above.
*/
Py_XINCREF(f); /* fool the link optimizer */
Py_XINCREF(f); /* fool the link optimizer */
Py_XINCREF(f); /* fool the link optimizer */
r = slp_eval_frame_value(f, throwflag, retval);
Py_XDECREF(f);
Py_XDECREF(f);
Expand Down Expand Up @@ -1708,8 +1708,10 @@ slp_eval_frame_value(PyFrameObject *f, int throwflag, PyObject *retval)

why = WHY_NOT;

if (throwflag) /* support for generator.throw() */
if (throwflag) { /* support for generator.throw() */
assert(retval == NULL); /* to prevent reference leaks */
goto error;
}


#ifdef STACKLESS
Expand All @@ -1733,6 +1735,7 @@ slp_eval_frame_value(PyFrameObject *f, int throwflag, PyObject *retval)
}
else if (!PyErr_Occurred()) {
/* iterator ended normally */
assert(retval == NULL); /* to prevent reference leaks */
retval = POP();
Py_DECREF(retval);
/* perform the delayed block jump */
Expand All @@ -1746,6 +1749,7 @@ slp_eval_frame_value(PyFrameObject *f, int throwflag, PyObject *retval)
if (tstate->c_tracefunc != NULL)
call_exc_trace(tstate->c_tracefunc, tstate->c_traceobj, tstate, f);
PyErr_Clear();
assert(retval == NULL); /* to prevent reference leaks */
retval = POP();
Py_DECREF(retval);
JUMPBY(oparg);
Expand Down
4 changes: 4 additions & 0 deletions Stackless/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ What's New in Stackless 3.X.X?

*Release date: 20XX-XX-XX*

- https://bitbucket.org/stackless-dev/stackless/issues/117
Fix various reference leaks:
- Leak of a reference to Py_None in generator.throw()

- https://bitbucket.org/stackless-dev/stackless/issues/111
Restore the Python ABI function PyGen_New(). Previously Stackless named this
function PyGenerator_New() and used a macro the redefine PyGen_New as
Expand Down
12 changes: 9 additions & 3 deletions Stackless/core/stacklesseval.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,17 @@ slp_gen_send_ex(PyGenObject *gen, PyObject *arg, int exc)
Py_INCREF(f);
ts->frame = f;

retval = Py_None;
Py_INCREF(retval);
if (exc)
retval = NULL;
else {
retval = Py_None;
Py_INCREF(retval);
}

if (stackless)
if (stackless) {
assert(exc == 0);
return STACKLESS_PACK(retval);
}
return slp_frame_dispatch(f, stopframe, exc, retval);
}

Expand Down

0 comments on commit 28e4aa6

Please sign in to comment.