Commit 97f8a229 authored by Stefan Behnel's avatar Stefan Behnel

simplify some Py3 precompiler checks

parent f913f4d3
...@@ -1941,7 +1941,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1941,7 +1941,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("/*--- Initialize various global constants etc. ---*/") code.putln("/*--- Initialize various global constants etc. ---*/")
code.putln(code.error_goto_if_neg("__Pyx_InitGlobals()", self.pos)) code.putln(code.error_goto_if_neg("__Pyx_InitGlobals()", self.pos))
code.putln("#if PY_VERSION_HEX < 0x03000000 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)") code.putln("#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)")
code.putln("if (__Pyx_init_sys_getdefaultencoding_params() < 0) %s" % code.error_goto(self.pos)) code.putln("if (__Pyx_init_sys_getdefaultencoding_params() < 0) %s" % code.error_goto(self.pos))
code.putln("#endif") code.putln("#endif")
......
...@@ -1388,7 +1388,7 @@ impl=""" ...@@ -1388,7 +1388,7 @@ impl="""
static CYTHON_INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x) { static CYTHON_INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x) {
const %(type)s neg_one = (%(type)s)-1, const_zero = 0; const %(type)s neg_one = (%(type)s)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero; const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000 #if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) { if (likely(PyInt_Check(x))) {
long val = PyInt_AS_LONG(x); long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) { if (is_unsigned && unlikely(val < 0)) {
...@@ -1461,7 +1461,7 @@ static CYTHON_INLINE %(type)s __Pyx_PyInt_from_py_%(TypeName)s(PyObject* x) { ...@@ -1461,7 +1461,7 @@ static CYTHON_INLINE %(type)s __Pyx_PyInt_from_py_%(TypeName)s(PyObject* x) {
#else #else
%(type)s val; %(type)s val;
PyObject *v = __Pyx_PyNumber_Int(x); PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_VERSION_HEX < 0x03000000 #if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) { if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v; PyObject *tmp = v;
v = PyNumber_Long(tmp); v = PyNumber_Long(tmp);
......
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