diff options
| author | shadchin <[email protected]> | 2023-06-18 21:03:32 +0300 |
|---|---|---|
| committer | shadchin <[email protected]> | 2023-06-18 21:03:32 +0300 |
| commit | e0ee27b73eae57d28e6c55ec99ab82371c153eaf (patch) | |
| tree | 93e413bb7b9206f6165c28d6f9dca8c5b57866a7 /contrib/tools/cython/Cython/Compiler | |
| parent | dc0626c403a73e8cea3729070454814636071bfe (diff) | |
Update Cython to 0.29.35
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler')
| -rw-r--r-- | contrib/tools/cython/Cython/Compiler/ModuleNode.py | 38 | ||||
| -rw-r--r-- | contrib/tools/cython/Cython/Compiler/Naming.py | 2 | ||||
| -rw-r--r-- | contrib/tools/cython/Cython/Compiler/Parsing.py | 11 | ||||
| -rw-r--r-- | contrib/tools/cython/Cython/Compiler/TypeSlots.py | 2 |
4 files changed, 33 insertions, 20 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/ModuleNode.py b/contrib/tools/cython/Cython/Compiler/ModuleNode.py index a9b1a492c4c..1e392a4e3a5 100644 --- a/contrib/tools/cython/Cython/Compiler/ModuleNode.py +++ b/contrib/tools/cython/Cython/Compiler/ModuleNode.py @@ -294,14 +294,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): cname = env.mangle(Naming.func_prefix_api, entry.name) sig = entry.type.signature_string() h_code.putln( - 'if (__Pyx_ImportFunction(module, "%s", (void (**)(void))&%s, "%s") < 0) goto bad;' - % (entry.name, cname, sig)) + 'if (__Pyx_ImportFunction_%s(module, "%s", (void (**)(void))&%s, "%s") < 0) goto bad;' + % (Naming.cyversion, entry.name, cname, sig)) for entry in api_vars: cname = env.mangle(Naming.varptr_prefix_api, entry.name) sig = entry.type.empty_declaration_code() h_code.putln( - 'if (__Pyx_ImportVoidPtr(module, "%s", (void **)&%s, "%s") < 0) goto bad;' - % (entry.name, cname, sig)) + 'if (__Pyx_ImportVoidPtr_%s(module, "%s", (void **)&%s, "%s") < 0) goto bad;' + % (Naming.cyversion, entry.name, cname, sig)) with ModuleImportGenerator(h_code, imported_modules={env.qualified_name: 'module'}) as import_generator: for entry in api_extension_types: self.generate_type_import_call(entry.type, h_code, import_generator, error_code="goto bad;") @@ -1508,28 +1508,25 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): have_gil=True) if base_type: + base_cname = base_type.typeptr_cname if needs_gc: # The base class deallocator probably expects this to be tracked, # so undo the untracking above. if base_type.scope and base_type.scope.needs_gc(): code.putln("PyObject_GC_Track(o);") else: - code.putln("#if CYTHON_USE_TYPE_SLOTS") - code.putln("if (PyType_IS_GC(Py_TYPE(o)->tp_base))") - code.putln("#endif") - code.putln("PyObject_GC_Track(o);") + code.putln("if (PyType_IS_GC(%s)) PyObject_GC_Track(o);" % base_cname) tp_dealloc = TypeSlots.get_base_slot_function(scope, tp_slot) if tp_dealloc is not None: code.putln("%s(o);" % tp_dealloc) elif base_type.is_builtin_type: - code.putln("%s->tp_dealloc(o);" % base_type.typeptr_cname) + code.putln("%s->tp_dealloc(o);" % base_cname) else: # This is an externally defined type. Calling through the # cimported base type pointer directly interacts badly with # the module cleanup, which may already have cleared it. # In that case, fall back to traversing the type hierarchy. - base_cname = base_type.typeptr_cname code.putln("if (likely(%s)) %s->tp_dealloc(o); " "else __Pyx_call_next_tp_dealloc(o, %s);" % ( base_cname, base_cname, slot_func_cname)) @@ -2964,7 +2961,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): cname = module.mangle(Naming.varptr_prefix, entry.name) signature = entry.type.empty_declaration_code() code.putln( - 'if (__Pyx_ImportVoidPtr(%s, "%s", (void **)&%s, "%s") < 0) %s' % ( + 'if (__Pyx_ImportVoidPtr_%s(%s, "%s", (void **)&%s, "%s") < 0) %s' % ( + Naming.cyversion, temp, entry.name, cname, signature, code.error_goto(self.pos))) code.put_decref_clear(temp, py_object_type) @@ -2989,7 +2987,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.put_gotref(temp) for entry in entries: code.putln( - 'if (__Pyx_ImportFunction(%s, "%s", (void (**)(void))&%s, "%s") < 0) %s' % ( + 'if (__Pyx_ImportFunction_%s(%s, "%s", (void (**)(void))&%s, "%s") < 0) %s' % ( + Naming.cyversion, temp, entry.name, entry.cname, @@ -3066,8 +3065,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): error_code = code.error_goto(error_pos) module = import_generator.imported_module(module_name, error_code) - code.put('%s = __Pyx_ImportType(%s, %s,' % ( + code.put('%s = __Pyx_ImportType_%s(%s, %s,' % ( type.typeptr_cname, + Naming.cyversion, module, module_name)) @@ -3085,12 +3085,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if not condition: code.putln("") # start in new line code.putln("#if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000") - code.putln('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT(%s),' % (objstruct, objstruct)) + code.putln('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT_%s(%s),' % ( + objstruct, Naming.cyversion, objstruct)) code.putln("#else") - code.putln('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT(%s),' % (sizeof_objstruct, sizeof_objstruct)) + code.putln('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT_%s(%s),' % ( + sizeof_objstruct, Naming.cyversion, sizeof_objstruct)) code.putln("#endif") else: - code.putln('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT(%s),' % (objstruct, objstruct)) + code.put('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT_%s(%s),' % ( + objstruct, Naming.cyversion, objstruct)) # check_size if type.check_size and type.check_size in ('error', 'warn', 'ignore'): @@ -3100,7 +3103,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): else: raise RuntimeError("invalid value for check_size '%s' when compiling %s.%s" % ( type.check_size, module_name, type.name)) - code.putln('__Pyx_ImportType_CheckSize_%s);' % check_size.title()) + code.put('__Pyx_ImportType_CheckSize_%s_%s);' % ( + check_size.title(), Naming.cyversion)) code.putln(' if (!%s) %s' % (type.typeptr_cname, error_code)) diff --git a/contrib/tools/cython/Cython/Compiler/Naming.py b/contrib/tools/cython/Cython/Compiler/Naming.py index 2c9b620788a..4dd6cbbd5cc 100644 --- a/contrib/tools/cython/Cython/Compiler/Naming.py +++ b/contrib/tools/cython/Cython/Compiler/Naming.py @@ -5,8 +5,10 @@ # Prefixes for generating C names. # Collected here to facilitate ensuring uniqueness. # +from .. import __version__ pyrex_prefix = "__pyx_" +cyversion = __version__.replace('.', '_') codewriter_temp_prefix = pyrex_prefix + "t_" diff --git a/contrib/tools/cython/Cython/Compiler/Parsing.py b/contrib/tools/cython/Cython/Compiler/Parsing.py index 20dbc9bbf95..378a41f0e14 100644 --- a/contrib/tools/cython/Cython/Compiler/Parsing.py +++ b/contrib/tools/cython/Cython/Compiler/Parsing.py @@ -2958,11 +2958,18 @@ def p_exception_value_clause(s): s.next() elif s.sy == '+': exc_check = '+' + plus_char_pos = s.position()[2] s.next() if s.sy == 'IDENT': name = s.systring - s.next() - exc_val = p_name(s, name) + if name == 'nogil': + if s.position()[2] == plus_char_pos + 1: + error(s.position(), + "'except +nogil' defines an exception handling function. Use 'except + nogil' for the 'nogil' modifier.") + # 'except + nogil' is parsed outside + else: + exc_val = p_name(s, name) + s.next() elif s.sy == '*': exc_val = ExprNodes.CharNode(s.position(), value=u'*') s.next() diff --git a/contrib/tools/cython/Cython/Compiler/TypeSlots.py b/contrib/tools/cython/Cython/Compiler/TypeSlots.py index c6867447d25..0ef17ede63e 100644 --- a/contrib/tools/cython/Cython/Compiler/TypeSlots.py +++ b/contrib/tools/cython/Cython/Compiler/TypeSlots.py @@ -906,7 +906,7 @@ slot_table = ( EmptySlot("tp_vectorcall", ifdef="PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)"), EmptySlot("tp_print", ifdef="PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000"), # PyPy specific extension - only here to avoid C compiler warnings. - EmptySlot("tp_pypy_flags", ifdef="CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000"), + EmptySlot("tp_pypy_flags", ifdef="CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000"), ) #------------------------------------------------------------------------------------------ |
