diff options
author | Lisandro Dalcin <dalcinl@gmail.com> | 2009-11-12 11:53:46 -0200 |
---|---|---|
committer | Lisandro Dalcin <dalcinl@gmail.com> | 2009-11-12 11:53:46 -0200 |
commit | f6d6e9980d0ad7454188e5498a422b58813e419e (patch) | |
tree | bf0402403c8fd20cf774020d1d576497402b3457 | |
parent | c7bc0930123424742d017d4b70d194fc3304aa3d (diff) | |
download | cython-0.12.rc0.tar.gz |
group definition of Py2/Py3 bytes/str compatibility macros in generated C code0.12.rc0
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 575414fc6..346ace0c3 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -454,7 +454,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln(" #define PyVarObject_HEAD_INIT(type, size) \\") code.putln(" PyObject_HEAD_INIT(type) size,") code.putln(" #define PyType_Modified(t)") - code.putln(" #define PyBytes_CheckExact PyString_CheckExact") code.putln("") code.putln(" typedef struct {") code.putln(" void *buf;") @@ -497,6 +496,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln(" #define PyBaseString_Type PyUnicode_Type") code.putln(" #define PyString_Type PyUnicode_Type") code.putln(" #define PyString_CheckExact PyUnicode_CheckExact") + code.putln("#else") + code.putln(" #define PyBytes_Type PyString_Type") + code.putln(" #define PyBytes_CheckExact PyString_CheckExact") + code.putln("#endif") + + code.putln("#if PY_MAJOR_VERSION >= 3") code.putln(" #define PyInt_Type PyLong_Type") code.putln(" #define PyInt_Check(op) PyLong_Check(op)") code.putln(" #define PyInt_CheckExact(op) PyLong_CheckExact(op)") @@ -519,7 +524,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): else: code.putln(" #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)") code.putln(" #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)") - code.putln(" #define PyBytes_Type PyString_Type") code.putln("#endif") code.putln("#if PY_MAJOR_VERSION >= 3") |