Skip to content

Commit cc52455

Browse files
author
Anselm Kruis
committed
Stackless issue python#70: stackless specific handling of C-return values
Add two assertions to suspicious functions. https://bitbucket.org/stackless-dev/stackless/issues/70 (grafted from bf3fa8395cd10e477bcc20b816cc659f1d5c8c0f)
1 parent b832adc commit cc52455

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Objects/abstract.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,6 +2668,7 @@ PyIter_Next(PyObject *iter)
26682668
STACKLESS_PROMOTE_METHOD(iter, tp_iternext);
26692669
result = (*iter->ob_type->tp_iternext)(iter);
26702670
STACKLESS_ASSERT();
2671+
STACKLESS_ASSERT_UNWINDING_VALUE_IS_NOT(result, NULL);
26712672
if (result == NULL &&
26722673
PyErr_Occurred() &&
26732674
PyErr_ExceptionMatches(PyExc_StopIteration))

Objects/typeobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4845,6 +4845,7 @@ wrap_next(PyObject *self, PyObject *args, void *wrapped)
48454845
STACKLESS_PROMOTE_ALL();
48464846
res = (*func)(self);
48474847
STACKLESS_ASSERT();
4848+
STACKLESS_ASSERT_UNWINDING_VALUE_IS_NOT(res, NULL);
48484849
if (res == NULL && !PyErr_Occurred())
48494850
PyErr_SetNone(PyExc_StopIteration);
48504851
return res;

Stackless/core/stackless_impl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ PyAPI_FUNC(PyTaskletObject *) slp_get_watchdog(PyThreadState *ts, int interrupt)
181181
#define STACKLESS_RETVAL(obj) \
182182
(STACKLESS_UNWINDING(obj) ? Py_UnwindToken->tempval : (obj))
183183

184+
#define STACKLESS_ASSERT_UNWINDING_VALUE_IS_NOT(obj, val) \
185+
assert(!STACKLESS_UNWINDING(obj) || ((Py_UnwindToken->tempval) != (val)))
186+
184187
/* macros for setting/resetting the stackless flag */
185188

186189
#define STACKLESS_GETARG() int stackless = (stackless = slp_try_stackless, \
@@ -555,6 +558,7 @@ PyObject * slp_get_channel_callback(void);
555558
#define STACKLESS_ASSERT() assert(1)
556559

557560
#define STACKLESS_RETVAL(obj) (obj)
561+
#define STACKLESS_ASSERT_UNWINDING_VALUE_IS_NOT(val) assert(1)
558562

559563
#define STACKLESS_DECLARE_METHOD(type, meth)
560564

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