Commit 327267f2 authored by Stefan Behnel's avatar Stefan Behnel

Remove redundant helper function "__Pyx_ImportModule()" which was only needed...

Remove redundant helper function "__Pyx_ImportModule()" which was only needed in Py<2.6 when PyObject_GetAttrString() and PyImport_ImportModule() did not take const string arguments.
parent d8645c03
......@@ -270,7 +270,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
h_code.putln("static %s = 0;" % type.declaration_code(cname))
h_code.putln("#define %s (*%s)" % (entry.name, cname))
h_code.put(UtilityCode.load_as_string("PyIdentifierFromString", "ImportExport.c")[0])
h_code.put(UtilityCode.load_as_string("ModuleImport", "ImportExport.c")[1])
if api_vars:
h_code.put(UtilityCode.load_as_string("VoidPtrImport", "ImportExport.c")[1])
if api_funcs:
......@@ -280,7 +279,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
h_code.putln("")
h_code.putln("static int import_%s(void) {" % self.api_name(env))
h_code.putln("PyObject *module = 0;")
h_code.putln('module = __Pyx_ImportModule("%s");' % env.qualified_name)
h_code.putln('module = PyImport_ImportModule("%s");' % env.qualified_name)
h_code.putln("if (!module) goto bad;")
for entry in api_funcs:
cname = env.mangle(Naming.func_prefix_api, entry.name)
......@@ -2903,13 +2902,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if entry.defined_in_pxd:
entries.append(entry)
if entries:
env.use_utility_code(
UtilityCode.load_cached("ModuleImport", "ImportExport.c"))
env.use_utility_code(
UtilityCode.load_cached("VoidPtrImport", "ImportExport.c"))
temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True)
code.putln(
'%s = __Pyx_ImportModule("%s"); if (!%s) %s' % (
'%s = PyImport_ImportModule("%s"); if (!%s) %s' % (
temp,
module.qualified_name,
temp,
......@@ -2933,13 +2930,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if entry.defined_in_pxd and entry.used:
entries.append(entry)
if entries:
env.use_utility_code(
UtilityCode.load_cached("ModuleImport", "ImportExport.c"))
env.use_utility_code(
UtilityCode.load_cached("FunctionImport", "ImportExport.c"))
temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True)
code.putln(
'%s = __Pyx_ImportModule("%s"); if (!%s) %s' % (
'%s = PyImport_ImportModule("%s"); if (!%s) %s' % (
temp,
module.qualified_name,
temp,
......@@ -3099,7 +3094,7 @@ class ModuleImportGenerator(object):
code = self.code
temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True)
self.temps.append(temp)
code.putln('%s = __Pyx_ImportModule(%s); if (unlikely(!%s)) %s' % (
code.putln('%s = PyImport_ImportModule(%s); if (unlikely(!%s)) %s' % (
temp, module_name_string, temp, error_code))
code.put_gotref(temp)
self.imported[module_name_string] = temp
......
......@@ -222,31 +222,6 @@ bad:
}
/////////////// ModuleImport.proto ///////////////
static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
/////////////// ModuleImport ///////////////
//@requires: PyIdentifierFromString
#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
PyObject *py_name = 0;
PyObject *py_module = 0;
py_name = __Pyx_PyIdentifier_FromString(name);
if (!py_name)
goto bad;
py_module = PyImport_Import(py_name);
Py_DECREF(py_name);
return py_module;
bad:
return 0;
}
#endif
/////////////// SetPackagePathFromImportLib.proto ///////////////
// PY_VERSION_HEX >= 0x03030000
......@@ -336,8 +311,6 @@ set_path:
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, int strict); /*proto*/
/////////////// TypeImport ///////////////
//@requires: PyIdentifierFromString
//@requires: ModuleImport
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
......@@ -345,19 +318,13 @@ static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name,
size_t size, int strict)
{
PyObject *result = 0;
PyObject *py_name = 0;
char warning[200];
Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
PyObject *py_basicsize;
#endif
py_name = __Pyx_PyIdentifier_FromString(class_name);
if (!py_name)
goto bad;
result = PyObject_GetAttr(module, py_name);
Py_DECREF(py_name);
py_name = 0;
result = PyObject_GetAttrString(module, class_name);
if (!result)
goto bad;
if (!PyType_Check(result)) {
......
......@@ -1168,11 +1168,15 @@ if (!__Pyx_RefNanny) {
//@substitute: naming
static void ${cleanup_cname}(PyObject *self); /*proto*/
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static int __Pyx_RegisterCleanup(void); /*proto*/
#else
#define __Pyx_RegisterCleanup() (0)
#endif
/////////////// RegisterModuleCleanup ///////////////
//@substitute: naming
//@requires: ImportExport.c::ModuleImport
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject* ${cleanup_cname}_atexit(PyObject *module, CYTHON_UNUSED PyObject *unused) {
......@@ -1202,7 +1206,7 @@ static int __Pyx_RegisterCleanup(void) {
if (!cleanup_func)
goto bad;
atexit = __Pyx_ImportModule("atexit");
atexit = PyImport_ImportModule("atexit");
if (!atexit)
goto bad;
reg = PyObject_GetAttrString(atexit, "_exithandlers");
......@@ -1244,12 +1248,6 @@ bad:
Py_XDECREF(res);
return ret;
}
#else
// fake call purely to work around "unused function" warning for __Pyx_ImportModule()
static int __Pyx_RegisterCleanup(void) {
(void)__Pyx_ImportModule; /* unused */
return 0;
}
#endif
/////////////// FastGil.init ///////////////
......
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