summaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Compiler/ModuleNode.py
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/cython/Cython/Compiler/ModuleNode.py
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler/ModuleNode.py')
-rw-r--r--contrib/tools/cython/Cython/Compiler/ModuleNode.py102
1 files changed, 51 insertions, 51 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/ModuleNode.py b/contrib/tools/cython/Cython/Compiler/ModuleNode.py
index cd7166408e0..b30be60dfe7 100644
--- a/contrib/tools/cython/Cython/Compiler/ModuleNode.py
+++ b/contrib/tools/cython/Cython/Compiler/ModuleNode.py
@@ -176,7 +176,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
h_guard = Naming.h_guard_prefix + self.api_name(env)
h_code.put_h_guard(h_guard)
h_code.putln("")
- h_code.putln('#include "Python.h"')
+ h_code.putln('#include "Python.h"')
self.generate_type_header_code(h_types, h_code)
if options.capi_reexport_cincludes:
self.generate_includes(env, [], h_code)
@@ -430,11 +430,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
except ImportError:
import xml.etree.ElementTree as ET
coverage_xml = ET.parse(coverage_xml_filename).getroot()
- if hasattr(coverage_xml, 'iter'):
- iterator = coverage_xml.iter() # Python 2.7 & 3.2+
- else:
- iterator = coverage_xml.getiterator()
- for el in iterator:
+ if hasattr(coverage_xml, 'iter'):
+ iterator = coverage_xml.iter() # Python 2.7 & 3.2+
+ else:
+ iterator = coverage_xml.getiterator()
+ for el in iterator:
el.tail = None # save some memory
else:
coverage_xml = None
@@ -580,17 +580,17 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
for entry in vtabslot_list:
self.generate_objstruct_predeclaration(entry.type, code)
vtabslot_entries = set(vtabslot_list)
- ctuple_names = set()
+ ctuple_names = set()
for module in modules:
definition = module is env
- type_entries = []
- for entry in module.type_entries:
- if entry.type.is_ctuple and entry.used:
- if entry.name not in ctuple_names:
- ctuple_names.add(entry.name)
+ type_entries = []
+ for entry in module.type_entries:
+ if entry.type.is_ctuple and entry.used:
+ if entry.name not in ctuple_names:
+ ctuple_names.add(entry.name)
type_entries.append(entry)
- elif definition or entry.defined_in_pxd:
- type_entries.append(entry)
+ elif definition or entry.defined_in_pxd:
+ type_entries.append(entry)
type_entries = [t for t in type_entries if t not in vtabslot_entries]
self.generate_type_header_code(type_entries, code)
for entry in vtabslot_list:
@@ -635,10 +635,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln(json.dumps(metadata, indent=4, sort_keys=True))
code.putln("END: Cython Metadata */")
code.putln("")
-
- code.putln("#ifndef PY_SSIZE_T_CLEAN")
+
+ code.putln("#ifndef PY_SSIZE_T_CLEAN")
code.putln("#define PY_SSIZE_T_CLEAN")
- code.putln("#endif /* PY_SSIZE_T_CLEAN */")
+ code.putln("#endif /* PY_SSIZE_T_CLEAN */")
for inc in sorted(env.c_includes.values(), key=IncludeCode.sortkey):
if inc.location == inc.INITIAL:
@@ -666,19 +666,19 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self._put_setup_code(code, "PythonCompatibility")
self._put_setup_code(code, "MathInitCode")
- # Using "(void)cname" to prevent "unused" warnings.
+ # Using "(void)cname" to prevent "unused" warnings.
if options.c_line_in_traceback:
- cinfo = "%s = %s; (void)%s; " % (Naming.clineno_cname, Naming.line_c_macro, Naming.clineno_cname)
+ cinfo = "%s = %s; (void)%s; " % (Naming.clineno_cname, Naming.line_c_macro, Naming.clineno_cname)
else:
cinfo = ""
- code.putln("#define __PYX_MARK_ERR_POS(f_index, lineno) \\")
- code.putln(" { %s = %s[f_index]; (void)%s; %s = lineno; (void)%s; %s}" % (
- Naming.filename_cname, Naming.filetable_cname, Naming.filename_cname,
- Naming.lineno_cname, Naming.lineno_cname,
- cinfo
- ))
- code.putln("#define __PYX_ERR(f_index, lineno, Ln_error) \\")
- code.putln(" { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }")
+ code.putln("#define __PYX_MARK_ERR_POS(f_index, lineno) \\")
+ code.putln(" { %s = %s[f_index]; (void)%s; %s = lineno; (void)%s; %s}" % (
+ Naming.filename_cname, Naming.filetable_cname, Naming.filename_cname,
+ Naming.lineno_cname, Naming.lineno_cname,
+ cinfo
+ ))
+ code.putln("#define __PYX_ERR(f_index, lineno, Ln_error) \\")
+ code.putln(" { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }")
code.putln("")
self.generate_extern_c_macro_definition(code)
@@ -1236,10 +1236,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
type = entry.type
scope = type.scope
if scope: # could be None if there was an error
- if not scope.directives['c_api_binop_methods']:
- error(self.pos,
- "The 'c_api_binop_methods' directive is only supported for forward compatibility"
- " and must be True.")
+ if not scope.directives['c_api_binop_methods']:
+ error(self.pos,
+ "The 'c_api_binop_methods' directive is only supported for forward compatibility"
+ " and must be True.")
self.generate_exttype_vtable(scope, code)
self.generate_new_function(scope, code, entry)
self.generate_dealloc_function(scope, code)
@@ -1571,11 +1571,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("{")
code.putln("PyObject *etype, *eval, *etb;")
code.putln("PyErr_Fetch(&etype, &eval, &etb);")
- # increase the refcount while we are calling into user code
- # to prevent recursive deallocation
- code.putln("__Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);")
+ # increase the refcount while we are calling into user code
+ # to prevent recursive deallocation
+ code.putln("__Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);")
code.putln("%s(o);" % entry.func_cname)
- code.putln("__Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);")
+ code.putln("__Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);")
code.putln("PyErr_Restore(etype, eval, etb);")
code.putln("}")
@@ -2315,7 +2315,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.exit_cfunc_scope() # done with labels
def generate_module_init_func(self, imported_modules, env, options, code):
- subfunction = self.mod_init_subfunction(self.pos, self.scope, code)
+ subfunction = self.mod_init_subfunction(self.pos, self.scope, code)
code.enter_cfunc_scope(self.scope)
code.putln("")
@@ -2413,8 +2413,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.put_error_if_neg(self.pos, "_import_array()")
code.putln("/*--- Threads initialization code ---*/")
- code.putln("#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 "
- "&& defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS")
+ code.putln("#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 "
+ "&& defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS")
code.putln("PyEval_InitThreads();")
code.putln("#endif")
@@ -2441,10 +2441,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if Options.cache_builtins:
code.putln("/*--- Builtin init code ---*/")
- code.put_error_if_neg(self.pos, "__Pyx_InitCachedBuiltins()")
+ code.put_error_if_neg(self.pos, "__Pyx_InitCachedBuiltins()")
code.putln("/*--- Constants init code ---*/")
- code.put_error_if_neg(self.pos, "__Pyx_InitCachedConstants()")
+ code.put_error_if_neg(self.pos, "__Pyx_InitCachedConstants()")
code.putln("/*--- Global type/function init code ---*/")
@@ -2535,7 +2535,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.exit_cfunc_scope()
- def mod_init_subfunction(self, pos, scope, orig_code):
+ def mod_init_subfunction(self, pos, scope, orig_code):
"""
Return a context manager that allows deviating the module init code generation
into a separate function and instead inserts a call to it.
@@ -2591,8 +2591,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("")
if needs_error_handling:
- self.call_code.putln(
- self.call_code.error_goto_if_neg("%s()" % self.cfunc_name, pos))
+ self.call_code.putln(
+ self.call_code.error_goto_if_neg("%s()" % self.cfunc_name, pos))
else:
self.call_code.putln("(void)%s();" % self.cfunc_name)
self.call_code = None
@@ -2671,8 +2671,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln('static void %s(CYTHON_UNUSED PyObject *self) {' %
Naming.cleanup_cname)
- code.enter_cfunc_scope(env)
-
+ code.enter_cfunc_scope(env)
+
if Options.generate_cleanup_code >= 2:
code.putln("/*--- Global cleanup code ---*/")
rev_entries = list(env.var_entries)
@@ -2962,7 +2962,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
module.qualified_name,
temp,
code.error_goto(self.pos)))
- code.put_gotref(temp)
+ code.put_gotref(temp)
for entry in entries:
if env is module:
cname = entry.cname
@@ -2973,8 +2973,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
'if (__Pyx_ImportVoidPtr(%s, "%s", (void **)&%s, "%s") < 0) %s' % (
temp, entry.name, cname, signature,
code.error_goto(self.pos)))
- code.put_decref_clear(temp, py_object_type)
- code.funcstate.release_temp(temp)
+ code.put_decref_clear(temp, py_object_type)
+ code.funcstate.release_temp(temp)
def generate_c_function_import_code_for_module(self, module, env, code):
# Generate import code for all exported C functions in a cimported module.
@@ -2992,7 +2992,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
module.qualified_name,
temp,
code.error_goto(self.pos)))
- code.put_gotref(temp)
+ code.put_gotref(temp)
for entry in entries:
code.putln(
'if (__Pyx_ImportFunction(%s, "%s", (void (**)(void))&%s, "%s") < 0) %s' % (
@@ -3001,8 +3001,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
entry.cname,
entry.type.signature_string(),
code.error_goto(self.pos)))
- code.put_decref_clear(temp, py_object_type)
- code.funcstate.release_temp(temp)
+ code.put_decref_clear(temp, py_object_type)
+ code.funcstate.release_temp(temp)
def generate_type_init_code(self, env, code):
# Generate type import code for extern extension types