Skip to content

Commit

Permalink
Issue python#112: Prepare Stackless 3.5, fix PEP492 for Stackless
Browse files Browse the repository at this point in the history
Fix various issues introduced by merging the PEP 492 implementation from default.

https://bitbucket.org/stackless-dev/stackless/issues/112
  • Loading branch information
Anselm Kruis committed Mar 12, 2017
1 parent ac32e1e commit 1c7ff3e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
7 changes: 6 additions & 1 deletion Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,18 @@ gen_throw(PyGenObject *gen, PyObject *args)
static PyObject *
gen_iternext(PyGenObject *gen)
{
STACKLESS_GETARG();
PyObject *retval;
if (((PyCodeObject*)gen->gi_code)->co_flags & CO_COROUTINE) {
PyErr_SetString(PyExc_TypeError,
"coroutine-objects do not support iteration");
return NULL;
}

return gen_send_ex(gen, NULL, 0);
STACKLESS_PROMOTE_ALL();
retval = gen_send_ex(gen, NULL, 0);
STACKLESS_ASSERT();
return retval;
}

/*
Expand Down
3 changes: 3 additions & 0 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -6485,6 +6485,7 @@ slot_tp_finalize(PyObject *self)
static PyObject *
slot_am_await(PyObject *self)
{
STACKLESS_GETARG(); /* not supported */
PyObject *func, *res;
_Py_IDENTIFIER(__await__);

Expand All @@ -6503,6 +6504,7 @@ slot_am_await(PyObject *self)
static PyObject *
slot_am_aiter(PyObject *self)
{
STACKLESS_GETARG(); /* not supported */
PyObject *func, *res;
_Py_IDENTIFIER(__aiter__);

Expand All @@ -6521,6 +6523,7 @@ slot_am_aiter(PyObject *self)
static PyObject *
slot_am_anext(PyObject *self)
{
STACKLESS_GETARG(); /* not supported */
PyObject *func, *res;
_Py_IDENTIFIER(__anext__);

Expand Down
28 changes: 10 additions & 18 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

/* enable more aggressive intra-module optimizations, where available */
#define PY_LOCAL_AGGRESSIVE
#undef PY_LOCAL_AGGRESSIVE

#include "Python.h"

Expand Down Expand Up @@ -1772,28 +1772,20 @@ slp_eval_frame_value(PyFrameObject *f, int throwflag, PyObject *retval)
}
}
else if (f->f_execute == slp_eval_frame_with_cleanup) {
/* finalise the WITH_CLEANUP operation */

/* finalise the WITH_CLEANUP_START operation */
if (retval) {
PyObject *u = TOP();
int err;
if (u != Py_None)
err = PyObject_IsTrue(retval);
else
err = 0;
Py_DECREF(retval);

if (err > 0) {
err = 0;
/* There was an exception and a True return */
PUSH(PyLong_FromLong((long) WHY_SILENCED));
}
/* XXX: The main loop contains a PREDICT(END_FINALLY).
/* recompute exc */
PyObject *exc = TOP();
if (PyLong_Check(exc))
exc = Py_None;
PUSH(exc);
PUSH(retval);
/* XXX: The main loop contains a PREDICT(WITH_CLEANUP_FINISH);
* I wonder, if we must use it here?
* If so, then set f_execute too.
*/
/*f->f_execute = PyEval_EvalFrame_value;
PREDICT(END_FINALLY); */
PREDICT(WITH_CLEANUP_FINISH); */
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion Stackless/core/stacklesseval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ gen_iternext_callback(PyFrameObject *f, int exc, PyObject *result)
* a leaking StopIteration into RuntimeError (with its cause
* set appropriately). */
if ((((PyCodeObject *)gen->gi_code)->co_flags &
CO_FUTURE_GENERATOR_STOP)
(CO_FUTURE_GENERATOR_STOP | CO_COROUTINE | CO_ITERABLE_COROUTINE))
&& PyErr_ExceptionMatches(PyExc_StopIteration))
{
PyObject *exc, *val, *val2, *tb;
Expand Down

0 comments on commit 1c7ff3e

Please sign in to comment.