Commit 604a770a authored by Stefan Behnel's avatar Stefan Behnel

clean up calls to helper functions in module init code

parent 3b6c1dde
...@@ -2064,7 +2064,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2064,7 +2064,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.put_setup_refcount_context(header3) code.put_setup_refcount_context(header3)
env.use_utility_code(UtilityCode.load("CheckBinaryVersion", "ModuleSetupCode.c")) env.use_utility_code(UtilityCode.load("CheckBinaryVersion", "ModuleSetupCode.c"))
code.putln("if ( __Pyx_check_binary_version() < 0) %s" % code.error_goto(self.pos)) code.put_error_if_neg(self.pos, "__Pyx_check_binary_version()")
code.putln("%s = PyTuple_New(0); %s" % ( code.putln("%s = PyTuple_New(0); %s" % (
Naming.empty_tuple, code.error_goto_if_null(Naming.empty_tuple, self.pos))) Naming.empty_tuple, code.error_goto_if_null(Naming.empty_tuple, self.pos)))
...@@ -2072,15 +2072,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2072,15 +2072,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos))) Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos)))
code.putln("#ifdef __Pyx_CyFunction_USED") code.putln("#ifdef __Pyx_CyFunction_USED")
code.putln("if (__Pyx_CyFunction_init() < 0) %s" % code.error_goto(self.pos)) code.put_error_if_neg(self.pos, "__Pyx_CyFunction_init()")
code.putln("#endif") code.putln("#endif")
code.putln("#ifdef __Pyx_FusedFunction_USED") code.putln("#ifdef __Pyx_FusedFunction_USED")
code.putln("if (__pyx_FusedFunction_init() < 0) %s" % code.error_goto(self.pos)) code.put_error_if_neg(self.pos, "__pyx_FusedFunction_init()")
code.putln("#endif") code.putln("#endif")
code.putln("#ifdef __Pyx_Generator_USED") code.putln("#ifdef __Pyx_Generator_USED")
code.putln("if (__pyx_Generator_init() < 0) %s" % code.error_goto(self.pos)) code.put_error_if_neg(self.pos, "__pyx_Generator_init()")
code.putln("#endif") code.putln("#endif")
code.putln("/*--- Library function declarations ---*/") code.putln("/*--- Library function declarations ---*/")
...@@ -2097,20 +2097,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2097,20 +2097,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self.generate_module_creation_code(env, code) self.generate_module_creation_code(env, code)
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.put_error_if_neg(self.pos, "__Pyx_InitGlobals()")
code.putln("#if PY_MAJOR_VERSION < 3 && (__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.put_error_if_neg(self.pos, "__Pyx_init_sys_getdefaultencoding_params()")
code.putln("#endif") code.putln("#endif")
__main__name = code.globalstate.get_py_string_const( __main__name = code.globalstate.get_py_string_const(
EncodedString("__main__"), identifier=True) EncodedString("__main__"), identifier=True)
code.putln("if (%s%s) {" % (Naming.module_is_main, self.full_module_name.replace('.', '__'))) code.putln("if (%s%s) {" % (Naming.module_is_main, self.full_module_name.replace('.', '__')))
code.putln( code.put_error_if_neg(self.pos, 'PyObject_SetAttrString(%s, "__name__", %s)' % (
'if (PyObject_SetAttrString(%s, "__name__", %s) < 0) %s;' % ( env.module_cname,
env.module_cname, __main__name.cname))
__main__name.cname,
code.error_goto(self.pos)))
code.putln("}") code.putln("}")
# set up __file__ and __path__, then add the module to sys.modules # set up __file__ and __path__, then add the module to sys.modules
...@@ -2118,10 +2116,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2118,10 +2116,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if Options.cache_builtins: if Options.cache_builtins:
code.putln("/*--- Builtin init code ---*/") code.putln("/*--- Builtin init code ---*/")
code.putln(code.error_goto_if_neg("__Pyx_InitCachedBuiltins()", self.pos)) code.put_error_if_neg(self.pos, "__Pyx_InitCachedBuiltins()")
code.putln("/*--- Constants init code ---*/") code.putln("/*--- Constants init code ---*/")
code.putln(code.error_goto_if_neg("__Pyx_InitCachedConstants()", self.pos)) code.put_error_if_neg(self.pos, "__Pyx_InitCachedConstants()")
code.putln("/*--- Global init code ---*/") code.putln("/*--- Global init code ---*/")
self.generate_global_init_code(env, code) self.generate_global_init_code(env, code)
......
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