Commit cd3ce37d authored by Stefan Behnel's avatar Stefan Behnel

Avoid using the "tp_iternext" slot when CYTHON_USE_TYPE_SLOTS is disabled.

parent c8f537ff
......@@ -2808,7 +2808,7 @@ class IteratorNode(ExprNode):
# PyObject_GetIter() fails if "tp_iternext" is not set, but the check below
# makes it visible to the C compiler that the pointer really isn't NULL, so that
# it can distinguish between the special cases and the generic case
code.putln("%s = Py_TYPE(%s)->tp_iternext; %s" % (
code.putln("%s = __Pyx_PyObject_GetIterNext(%s); %s" % (
self.iter_func_ptr, self.py_result(),
code.error_goto_if_null(self.iter_func_ptr, self.pos)))
if self.may_be_a_sequence:
......@@ -7775,7 +7775,7 @@ class SequenceNode(ExprNode):
rhs.generate_disposal_code(code)
iternext_func = code.funcstate.allocate_temp(self._func_iternext_type, manage_ref=False)
code.putln("%s = Py_TYPE(%s)->tp_iternext;" % (
code.putln("%s = __Pyx_PyObject_GetIterNext(%s);" % (
iternext_func, iterator_temp))
unpacking_error_label = code.new_label('unpacking_failed')
......
......@@ -44,11 +44,7 @@ static CYTHON_INLINE PyObject* __Pyx_Generator_Yield_From(__pyx_CoroutineObject
return NULL;
}
// source_gen is now the iterator, make the first next() call
#if CYTHON_USE_TYPE_SLOTS
retval = Py_TYPE(source_gen)->tp_iternext(source_gen);
#else
retval = PyIter_Next(source_gen);
#endif
retval = __Pyx_PyObject_GetIterNext(source_gen)(source_gen);
}
if (likely(retval)) {
gen->yieldfrom = source_gen;
......@@ -77,11 +73,7 @@ static PyObject* __Pyx__Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen,
if (__Pyx_Coroutine_Check(source_gen)) {
retval = __Pyx_Generator_Next(source_gen);
} else {
#if CYTHON_USE_TYPE_SLOTS
retval = Py_TYPE(source_gen)->tp_iternext(source_gen);
#else
retval = PyIter_Next(source_gen);
#endif
retval = __Pyx_PyObject_GetIterNext(source_gen)(source_gen);
}
if (retval) {
gen->yieldfrom = source_gen;
......@@ -857,7 +849,7 @@ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
#endif
{
if (value == Py_None)
ret = Py_TYPE(yf)->tp_iternext(yf);
ret = __Pyx_PyObject_GetIterNext(yf)(yf);
else
ret = __Pyx_PyObject_CallMethod1(yf, PYIDENT("send"), value);
}
......@@ -955,7 +947,7 @@ static PyObject *__Pyx_Generator_Next(PyObject *self) {
ret = __Pyx_Coroutine_Send(yf, Py_None);
} else
#endif
ret = Py_TYPE(yf)->tp_iternext(yf);
ret = __Pyx_PyObject_GetIterNext(yf)(yf);
gen->is_running = 0;
//Py_DECREF(yf);
if (likely(ret)) {
......
......@@ -711,8 +711,10 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0)
#define __Pyx_PyObject_GetIterNext(obj) (Py_TYPE(obj)->tp_iternext)
#else
#define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature)
#define __Pyx_PyObject_GetIterNext(obj) PyIter_Next
#endif
#if CYTHON_COMPILING_IN_LIMITED_API
......
......@@ -133,7 +133,7 @@ static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyOb
if (unlikely(!iter)) goto bad;
if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
iternext = Py_TYPE(iter)->tp_iternext;
iternext = __Pyx_PyObject_GetIterNext(iter);
value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment