Commit 500f9a40 authored by Stefan Behnel's avatar Stefan Behnel

minor code simplification in utility functions by using macro for Py2/3...

minor code simplification in utility functions by using macro for Py2/3 dependent PyString/PyUnicode_FromString() calls
parent 589cbe8d
...@@ -566,8 +566,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -566,8 +566,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else #else
#define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif #endif
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
...@@ -2475,11 +2477,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { ...@@ -2475,11 +2477,7 @@ static PyObject *__Pyx_ImportModule(const char *name) {
PyObject *py_name = 0; PyObject *py_name = 0;
PyObject *py_module = 0; PyObject *py_module = 0;
#if PY_MAJOR_VERSION < 3 py_name = __Pyx_PyIdentifier_FromString(name);
py_name = PyString_FromString(name);
#else
py_name = PyUnicode_FromString(name);
#endif
if (!py_name) if (!py_name)
goto bad; goto bad;
py_module = PyImport_Import(py_name); py_module = PyImport_Import(py_name);
...@@ -2512,11 +2510,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class ...@@ -2512,11 +2510,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
py_module = __Pyx_ImportModule(module_name); py_module = __Pyx_ImportModule(module_name);
if (!py_module) if (!py_module)
goto bad; goto bad;
#if PY_MAJOR_VERSION < 3 py_name = __Pyx_PyIdentifier_FromString(class_name);
py_name = PyString_FromString(class_name);
#else
py_name = PyUnicode_FromString(class_name);
#endif
if (!py_name) if (!py_name)
goto bad; goto bad;
result = PyObject_GetAttr(py_module, py_name); result = PyObject_GetAttr(py_module, py_name);
......
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