Commit 2a07d9a0 authored by Stefan Behnel's avatar Stefan Behnel

merged PyPy branch into mainline

parents 26032d37 8fbf75ab
...@@ -1910,6 +1910,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1910,6 +1910,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# if entry.type.is_pyobject and entry.used: # if entry.type.is_pyobject and entry.used:
# code.putln("Py_DECREF(%s); %s = 0;" % ( # code.putln("Py_DECREF(%s); %s = 0;" % (
# code.entry_as_pyobject(entry), entry.cname)) # code.entry_as_pyobject(entry), entry.cname))
code.putln('#if CYTHON_COMPILING_IN_PYPY')
code.putln('Py_CLEAR(%s);' % Naming.builtins_cname)
code.putln('#endif')
code.putln("Py_INCREF(Py_None); return Py_None;") code.putln("Py_INCREF(Py_None); return Py_None;")
def generate_main_method(self, env, code): def generate_main_method(self, env, code):
...@@ -1968,7 +1971,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1968,7 +1971,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"if (!%s) %s;" % ( "if (!%s) %s;" % (
env.module_cname, env.module_cname,
code.error_goto(self.pos))); code.error_goto(self.pos)))
code.putln("#if PY_MAJOR_VERSION < 3") code.putln("#if PY_MAJOR_VERSION < 3")
code.putln( code.putln(
"Py_INCREF(%s);" % "Py_INCREF(%s);" %
...@@ -1980,7 +1983,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1980,7 +1983,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"if (!%s) %s;" % ( "if (!%s) %s;" % (
Naming.builtins_cname, Naming.builtins_cname,
code.error_goto(self.pos))); code.error_goto(self.pos)))
code.putln('#if CYTHON_COMPILING_IN_PYPY')
code.putln('Py_INCREF(%s);' % Naming.builtins_cname)
code.putln('#endif')
code.putln( code.putln(
'if (__Pyx_SetAttrString(%s, "__builtins__", %s) < 0) %s;' % ( 'if (__Pyx_SetAttrString(%s, "__builtins__", %s) < 0) %s;' % (
env.module_cname, env.module_cname,
...@@ -1994,7 +2000,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1994,7 +2000,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"if (!%s) %s;" % ( "if (!%s) %s;" % (
Naming.preimport_cname, Naming.preimport_cname,
code.error_goto(self.pos))); code.error_goto(self.pos)))
def generate_global_init_code(self, env, code): def generate_global_init_code(self, env, code):
# Generate code to initialise global PyObject * # Generate code to initialise global PyObject *
...@@ -2208,6 +2214,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2208,6 +2214,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# a significant performance hit. (See trac #561.) # a significant performance hit. (See trac #561.)
for func in entry.type.scope.pyfunc_entries: for func in entry.type.scope.pyfunc_entries:
if func.is_special and Options.docstrings and func.wrapperbase_cname: if func.is_special and Options.docstrings and func.wrapperbase_cname:
code.putln('#if CYTHON_COMPILING_IN_CPYTHON')
code.putln("{") code.putln("{")
code.putln( code.putln(
'PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&%s, "%s"); %s' % ( 'PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&%s, "%s"); %s' % (
...@@ -2226,6 +2233,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2226,6 +2233,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
func.wrapperbase_cname)) func.wrapperbase_cname))
code.putln("}") code.putln("}")
code.putln("}") code.putln("}")
code.putln('#endif')
if type.vtable_cname: if type.vtable_cname:
code.putln( code.putln(
"if (__Pyx_SetVtable(%s.tp_dict, %s) < 0) %s" % ( "if (__Pyx_SetVtable(%s.tp_dict, %s) < 0) %s" % (
......
...@@ -3429,8 +3429,10 @@ class DefNodeWrapper(FuncDefNode): ...@@ -3429,8 +3429,10 @@ class DefNodeWrapper(FuncDefNode):
split_string_literal(escape_byte_string(docstr)))) split_string_literal(escape_byte_string(docstr))))
if entry.is_special: if entry.is_special:
code.putln('#if CYTHON_COMPILING_IN_CPYTHON')
code.putln( code.putln(
"struct wrapperbase %s;" % entry.wrapperbase_cname) "struct wrapperbase %s;" % entry.wrapperbase_cname)
code.putln('#endif')
if with_pymethdef or self.target.fused_py_func: if with_pymethdef or self.target.fused_py_func:
code.put( code.put(
...@@ -8389,19 +8391,19 @@ else: ...@@ -8389,19 +8391,19 @@ else:
printing_utility_code = UtilityCode( printing_utility_code = UtilityCode(
proto = """ proto = """
static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/ static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/
#if PY_MAJOR_VERSION >= 3 #if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
static PyObject* %s = 0; static PyObject* %s = 0;
static PyObject* %s = 0; static PyObject* %s = 0;
#endif #endif
""" % (Naming.print_function, Naming.print_function_kwargs), """ % (Naming.print_function, Naming.print_function_kwargs),
cleanup = """ cleanup = """
#if PY_MAJOR_VERSION >= 3 #if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
Py_CLEAR(%s); Py_CLEAR(%s);
Py_CLEAR(%s); Py_CLEAR(%s);
#endif #endif
""" % (Naming.print_function, Naming.print_function_kwargs), """ % (Naming.print_function, Naming.print_function_kwargs),
impl = r""" impl = r"""
#if PY_MAJOR_VERSION < 3 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) { static PyObject *__Pyx_GetStdout(void) {
PyObject *f = PySys_GetObject((char *)"stdout"); PyObject *f = PySys_GetObject((char *)"stdout");
if (!f) { if (!f) {
...@@ -8511,7 +8513,7 @@ proto = """ ...@@ -8511,7 +8513,7 @@ proto = """
static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/ static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/
""", """,
impl = r""" impl = r"""
#if PY_MAJOR_VERSION < 3 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static int __Pyx_PrintOne(PyObject* f, PyObject *o) { static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
if (!f) { if (!f) {
......
...@@ -367,7 +367,7 @@ class Scope(object): ...@@ -367,7 +367,7 @@ class Scope(object):
# name is not None. Reports a warning if already # name is not None. Reports a warning if already
# declared. # declared.
if type.is_buffer and not isinstance(self, LocalScope): if type.is_buffer and not isinstance(self, LocalScope):
error(pos, ERR_BUF_LOCALONLY) error(pos, 'Buffer types only allowed as function local variables')
if not self.in_cinclude and cname and re.match("^_[_A-Z]+$", cname): if not self.in_cinclude and cname and re.match("^_[_A-Z]+$", cname):
# See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names # See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names
warning(pos, "'%s' is a reserved name in C." % cname, -1) warning(pos, "'%s' is a reserved name in C." % cname, -1)
...@@ -1635,7 +1635,7 @@ class ClassScope(Scope): ...@@ -1635,7 +1635,7 @@ class ClassScope(Scope):
# right thing in this scope (as the class memebers aren't still functions). # right thing in this scope (as the class memebers aren't still functions).
# Don't want to add a cfunction to this scope 'cause that would mess with # Don't want to add a cfunction to this scope 'cause that would mess with
# the type definition, so we just return the right entry. # the type definition, so we just return the right entry.
self.use_utility_code(classmethod_utility_code) self.use_utility_code(Code.UtilityCode.load_cached("ClassMethod", "CythonFunction.c"))
entry = Entry( entry = Entry(
"classmethod", "classmethod",
"__Pyx_Method_ClassMethod", "__Pyx_Method_ClassMethod",
...@@ -2093,53 +2093,3 @@ class PropertyScope(Scope): ...@@ -2093,53 +2093,3 @@ class PropertyScope(Scope):
error(pos, "Only __get__, __set__ and __del__ methods allowed " error(pos, "Only __get__, __set__ and __del__ methods allowed "
"in a property declaration") "in a property declaration")
return None return None
# Should this go elsewhere (and then get imported)?
#------------------------------------------------------------------------------------
classmethod_utility_code = Code.UtilityCode(
proto = """
#include "descrobject.h"
static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
""",
impl = """
static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
/* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */
static PyTypeObject *methoddescr_type = NULL;
if (methoddescr_type == NULL) {
PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append");
if (!meth) return NULL;
methoddescr_type = Py_TYPE(meth);
Py_DECREF(meth);
}
if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */
PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
#if PY_VERSION_HEX < 0x03020000
PyTypeObject *d_type = descr->d_type;
#else
PyTypeObject *d_type = descr->d_common.d_type;
#endif
return PyDescr_NewClassMethod(d_type, descr->d_method);
}
else if (PyMethod_Check(method)) { /* python classes */
return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
}
else if (PyCFunction_Check(method)) {
return PyClassMethod_New(method);
}
#ifdef __Pyx_CyFunction_USED
else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) {
return PyClassMethod_New(method);
}
#endif
PyErr_Format(PyExc_TypeError,
"Class-level classmethod() can only be called on "
"a method_descriptor or instance method.");
return NULL;
}
""")
#------------------------------------------------------------------------------------
ERR_BUF_LOCALONLY = 'Buffer types only allowed as function local variables'
...@@ -881,3 +881,51 @@ static int __pyx_FusedFunction_init(void) { ...@@ -881,3 +881,51 @@ static int __pyx_FusedFunction_init(void) {
__pyx_FusedFunctionType = &__pyx_FusedFunctionType_type; __pyx_FusedFunctionType = &__pyx_FusedFunctionType_type;
return 0; return 0;
} }
//////////////////// ClassMethod.proto ////////////////////
#include "descrobject.h"
static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
//////////////////// ClassMethod ////////////////////
static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
#if CYTHON_COMPILING_IN_PYPY
if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) { /* cdef classes */
return PyClassMethod_New(method);
}
#else
/* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */
static PyTypeObject *methoddescr_type = NULL;
if (methoddescr_type == NULL) {
PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append");
if (!meth) return NULL;
methoddescr_type = Py_TYPE(meth);
Py_DECREF(meth);
}
if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */
PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
#if PY_VERSION_HEX < 0x03020000
PyTypeObject *d_type = descr->d_type;
#else
PyTypeObject *d_type = descr->d_common.d_type;
#endif
return PyDescr_NewClassMethod(d_type, descr->d_method);
}
#endif
else if (PyMethod_Check(method)) { /* python classes */
return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
}
else if (PyCFunction_Check(method)) {
return PyClassMethod_New(method);
}
#ifdef __Pyx_CyFunction_USED
else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) {
return PyClassMethod_New(method);
}
#endif
PyErr_Format(PyExc_TypeError,
"Class-level classmethod() can only be called on "
"a method_descriptor or instance method.");
return NULL;
}
...@@ -200,6 +200,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); ...@@ -200,6 +200,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *local_type, *local_value, *local_tb; PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb; PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET(); PyThreadState *tstate = PyThreadState_GET();
local_type = tstate->curexc_type; local_type = tstate->curexc_type;
...@@ -208,19 +209,27 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) ...@@ -208,19 +209,27 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
tstate->curexc_type = 0; tstate->curexc_type = 0;
tstate->curexc_value = 0; tstate->curexc_value = 0;
tstate->curexc_traceback = 0; tstate->curexc_traceback = 0;
#else
PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
PyErr_NormalizeException(&local_type, &local_value, &local_tb); PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(tstate->curexc_type)) if (unlikely(tstate->curexc_type))
#else
if (unlikely(PyErr_Occurred()))
#endif
goto bad; goto bad;
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
goto bad; goto bad;
#endif #endif
*type = local_type;
*value = local_value;
*tb = local_tb;
Py_INCREF(local_type); Py_INCREF(local_type);
Py_INCREF(local_value); Py_INCREF(local_value);
Py_INCREF(local_tb); Py_INCREF(local_tb);
*type = local_type;
*value = local_value;
*tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
tmp_type = tstate->exc_type; tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value; tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback; tmp_tb = tstate->exc_traceback;
...@@ -228,10 +237,13 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) ...@@ -228,10 +237,13 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
tstate->exc_value = local_value; tstate->exc_value = local_value;
tstate->exc_traceback = local_tb; tstate->exc_traceback = local_tb;
/* Make sure tstate is in a consistent state when we XDECREF /* Make sure tstate is in a consistent state when we XDECREF
these objects (XDECREF may run arbitrary code). */ these objects (DECREF may run arbitrary code). */
Py_XDECREF(tmp_type); Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value); Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb); Py_XDECREF(tmp_tb);
#else
PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
return 0; return 0;
bad: bad:
*type = 0; *type = 0;
...@@ -251,6 +263,7 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); ...@@ -251,6 +263,7 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb);
/////////////// SaveResetException /////////////// /////////////// SaveResetException ///////////////
static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET(); PyThreadState *tstate = PyThreadState_GET();
*type = tstate->exc_type; *type = tstate->exc_type;
*value = tstate->exc_value; *value = tstate->exc_value;
...@@ -258,9 +271,13 @@ static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, ...@@ -258,9 +271,13 @@ static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value,
Py_XINCREF(*type); Py_XINCREF(*type);
Py_XINCREF(*value); Py_XINCREF(*value);
Py_XINCREF(*tb); Py_XINCREF(*tb);
#else
PyErr_GetExcInfo(type, value, tb);
#endif
} }
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb; PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET(); PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->exc_type; tmp_type = tstate->exc_type;
...@@ -272,6 +289,9 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) ...@@ -272,6 +289,9 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb)
Py_XDECREF(tmp_type); Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value); Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb); Py_XDECREF(tmp_tb);
#else
PyErr_SetExcInfo(type, value, tb);
#endif
} }
/////////////// SwapException.proto /////////////// /////////////// SwapException.proto ///////////////
...@@ -282,6 +302,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, ...@@ -282,6 +302,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value,
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb; PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET(); PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->exc_type; tmp_type = tstate->exc_type;
...@@ -291,6 +312,10 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, ...@@ -291,6 +312,10 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value,
tstate->exc_type = *type; tstate->exc_type = *type;
tstate->exc_value = *value; tstate->exc_value = *value;
tstate->exc_traceback = *tb; tstate->exc_traceback = *tb;
#else
PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
PyErr_SetExcInfo(*type, *value, *tb);
#endif
*type = tmp_type; *type = tmp_type;
*value = tmp_value; *value = tmp_value;
......
...@@ -121,6 +121,12 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( ...@@ -121,6 +121,12 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
{ {
PyObject* key = 0; PyObject* key = 0;
Py_ssize_t pos = 0; Py_ssize_t pos = 0;
#if CPYTHON_COMPILING_IN_PYPY
/* PyPy appears to check keywords at call time, not at unpacking time => not much to do here */
if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
goto invalid_keyword;
return 1;
#else
while (PyDict_Next(kwdict, &pos, &key, 0)) { while (PyDict_Next(kwdict, &pos, &key, 0)) {
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
...@@ -136,6 +142,7 @@ invalid_keyword_type: ...@@ -136,6 +142,7 @@ invalid_keyword_type:
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%s() keywords must be strings", function_name); "%s() keywords must be strings", function_name);
return 0; return 0;
#endif
invalid_keyword: invalid_keyword:
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
......
...@@ -506,12 +506,14 @@ static void __Pyx_Generator_del(PyObject *self) { ...@@ -506,12 +506,14 @@ static void __Pyx_Generator_del(PyObject *self) {
_Py_NewReference(self); _Py_NewReference(self);
self->ob_refcnt = refcnt; self->ob_refcnt = refcnt;
} }
#if CYTHON_COMPILING_FOR_CPYTHON
assert(PyType_IS_GC(self->ob_type) && assert(PyType_IS_GC(self->ob_type) &&
_Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
* we need to undo that. */ * we need to undo that. */
_Py_DEC_REFTOTAL; _Py_DEC_REFTOTAL;
#endif
/* If Py_TRACE_REFS, _Py_NewReference re-added self to the object /* If Py_TRACE_REFS, _Py_NewReference re-added self to the object
* chain, so no more to do there. * chain, so no more to do there.
* If COUNT_ALLOCS, the original decref bumped tp_frees, and * If COUNT_ALLOCS, the original decref bumped tp_frees, and
......
...@@ -119,10 +119,17 @@ static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1 ...@@ -119,10 +119,17 @@ static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1
__Pyx_UnpackTupleError(tuple, 2); __Pyx_UnpackTupleError(tuple, 2);
goto bad; goto bad;
} }
#if CYTHON_COMPILING_IN_PYPY
value1 = PySequence_GetItem(tuple, 0);
if (unlikely(!value1)) goto bad;
value2 = PySequence_GetItem(tuple, 1);
if (unlikely(!value2)) goto bad;
#else
value1 = PyTuple_GET_ITEM(tuple, 0); value1 = PyTuple_GET_ITEM(tuple, 0);
value2 = PyTuple_GET_ITEM(tuple, 1); value2 = PyTuple_GET_ITEM(tuple, 1);
Py_INCREF(value1); Py_INCREF(value1);
Py_INCREF(value2); Py_INCREF(value2);
#endif
if (decref_tuple) { Py_DECREF(tuple); } if (decref_tuple) { Py_DECREF(tuple); }
} }
*pvalue1 = value1; *pvalue1 = value1;
......
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