simplify some Py3 precompiler checks
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 9 Mar 2013 13:24:31 +0000 (14:24 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 9 Mar 2013 13:24:31 +0000 (14:24 +0100)
Cython/Compiler/ModuleNode.py
Cython/Compiler/PyrexTypes.py

index aeb2cad..5021754 100644 (file)
@@ -1941,7 +1941,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         code.putln("/*--- Initialize various global constants etc. ---*/")
         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("#endif")
 
index 4896c2a..52bf076 100755 (executable)
@@ -1388,7 +1388,7 @@ impl="""
 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 int is_unsigned = neg_one > const_zero;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
     if (likely(PyInt_Check(x))) {
         long val = PyInt_AS_LONG(x);
         if (is_unsigned && unlikely(val < 0)) {
@@ -1461,7 +1461,7 @@ static CYTHON_INLINE %(type)s __Pyx_PyInt_from_py_%(TypeName)s(PyObject* x) {
         #else
         %(type)s val;
         PyObject *v = __Pyx_PyNumber_Int(x);
-        #if PY_VERSION_HEX < 0x03000000
+        #if PY_MAJOR_VERSION < 3
         if (likely(v) && !PyLong_Check(v)) {
             PyObject *tmp = v;
             v = PyNumber_Long(tmp);