Skip to content

Commit

Permalink
Stackless issue python#70: stackless specific handling of C-return va…
Browse files Browse the repository at this point in the history
…lues

If a C-function checks a return value of another C-function of type PyObject*,
it must handle the case of unwinding. This commit fixes PyObject_Call in
abstract.c.

https://bitbucket.org/stackless-dev/stackless/issues/70
(grafted from 113b9eaa4dd219a4f249f082f6772b9e5086e1a5)
  • Loading branch information
Anselm Kruis committed Nov 8, 2016
1 parent 4e39aad commit 7a978ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
if (!stackless)
#endif
Py_LeaveRecursiveCall();
if (result == NULL && !PyErr_Occurred())
if (STACKLESS_RETVAL(result) == NULL && !PyErr_Occurred())
PyErr_SetString(
PyExc_SystemError,
"NULL result without error in PyObject_Call");
Expand Down
5 changes: 5 additions & 0 deletions Stackless/core/stackless_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ PyAPI_FUNC(PyTaskletObject *) slp_get_watchdog(PyThreadState *ts, int interrupt)
/* an arbitrary positive number */
#define STACKLESS_UNWINDING_MAGIC 0x7fedcba9

#define STACKLESS_RETVAL(obj) \
(STACKLESS_UNWINDING(obj) ? Py_UnwindToken->tempval : (obj))

/* macros for setting/resetting the stackless flag */

#define STACKLESS_GETARG() int stackless = (stackless = slp_try_stackless, \
Expand Down Expand Up @@ -551,6 +554,8 @@ PyObject * slp_get_channel_callback(void);
#define STACKLESS_RETRACT() assert(1)
#define STACKLESS_ASSERT() assert(1)

#define STACKLESS_RETVAL(obj) (obj)

#define STACKLESS_DECLARE_METHOD(type, meth)

#endif /* STACKLESS */
Expand Down

0 comments on commit 7a978ae

Please sign in to comment.