Skip to content

Commit 7a978ae

Browse files
author
Anselm Kruis
committed
Stackless issue python#70: stackless specific handling of C-return values
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)
1 parent 4e39aad commit 7a978ae

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Objects/abstract.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
20482048
if (!stackless)
20492049
#endif
20502050
Py_LeaveRecursiveCall();
2051-
if (result == NULL && !PyErr_Occurred())
2051+
if (STACKLESS_RETVAL(result) == NULL && !PyErr_Occurred())
20522052
PyErr_SetString(
20532053
PyExc_SystemError,
20542054
"NULL result without error in PyObject_Call");

Stackless/core/stackless_impl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ PyAPI_FUNC(PyTaskletObject *) slp_get_watchdog(PyThreadState *ts, int interrupt)
178178
/* an arbitrary positive number */
179179
#define STACKLESS_UNWINDING_MAGIC 0x7fedcba9
180180

181+
#define STACKLESS_RETVAL(obj) \
182+
(STACKLESS_UNWINDING(obj) ? Py_UnwindToken->tempval : (obj))
183+
181184
/* macros for setting/resetting the stackless flag */
182185

183186
#define STACKLESS_GETARG() int stackless = (stackless = slp_try_stackless, \
@@ -551,6 +554,8 @@ PyObject * slp_get_channel_callback(void);
551554
#define STACKLESS_RETRACT() assert(1)
552555
#define STACKLESS_ASSERT() assert(1)
553556

557+
#define STACKLESS_RETVAL(obj) (obj)
558+
554559
#define STACKLESS_DECLARE_METHOD(type, meth)
555560

556561
#endif /* STACKLESS */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy