]> git.pld-linux.org Git - packages/python-Cython.git/commitdiff
- added gc-py2-fix backported from git (fixes python2 crash in generated deallocation... master auto/th/python-Cython-0.29.36-2
authorJakub Bogusz <qboosh@pld-linux.org>
Sat, 23 Sep 2023 19:17:21 +0000 (21:17 +0200)
committerJakub Bogusz <qboosh@pld-linux.org>
Sat, 23 Sep 2023 19:17:21 +0000 (21:17 +0200)
cython-gc-py2-fix.patch [new file with mode: 0644]
python-Cython.spec

diff --git a/cython-gc-py2-fix.patch b/cython-gc-py2-fix.patch
new file mode 100644 (file)
index 0000000..e11d0b3
--- /dev/null
@@ -0,0 +1,28 @@
+From 039ef7c6242b3b6a18363ff22ead04f4e7cce676 Mon Sep 17 00:00:00 2001
+From: Stefan Behnel <stefan_ml@behnel.de>
+Date: Fri, 14 Jul 2023 21:46:56 +0200
+Subject: [PATCH] In Py2, the extension type might get cleaned up before the
+ objects at system exit, so we need an extra NULL check for the type pointer.
+
+---
+ Cython/Compiler/ModuleNode.py | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
+index f98a0c15054..bf2cc63e1e1 100644
+--- a/Cython/Compiler/ModuleNode.py
++++ b/Cython/Compiler/ModuleNode.py
+@@ -1509,7 +1509,13 @@ class ModuleNode(Nodes.Node, Nodes.Block
+                 if base_type.scope and base_type.scope.needs_gc():
+                     code.putln("PyObject_GC_Track(o);")
+                 else:
++                    code.putln("#if PY_MAJOR_VERSION < 3")
++                    # Py2 lacks guarantees that the type pointer is still valid if we dealloc the object
++                    # at system exit time.  Thus, we need an extra NULL check.
++                    code.putln("if (!(%s) || PyType_IS_GC(%s)) PyObject_GC_Track(o);" % (base_cname, base_cname))
++                    code.putln("#else")
+                     code.putln("if (PyType_IS_GC(%s)) PyObject_GC_Track(o);" % base_cname)
++                    code.putln("#endif")
+             tp_dealloc = TypeSlots.get_base_slot_function(scope, tp_slot)
+             if tp_dealloc is not None:
index 5308128c1680a63b42af9a84af931c5e3027388a..4b8587b69fba81d0292a9983e484d9bce20856ad 100644 (file)
@@ -11,12 +11,13 @@ Summary:    Language for writing Python Extension Modules (Python 2.x version)
 Summary(pl.UTF-8):     Język służący do pisania modułów rozszerzających Pythona (wersja dla Pythona 2.x)
 Name:          python-%{module}
 Version:       0.29.36
-Release:       1
+Release:       2
 License:       Apache v2.0
 Group:         Libraries/Python
 #Source0Download: https://pypi.org/simple/cython/
 Source0:       https://files.pythonhosted.org/packages/source/c/cython/%{module}-%{version}.tar.gz
 # Source0-md5: a4d0f9fbc9c137f1a88937cd40e8c5ee
+Patch0:                cython-gc-py2-fix.patch
 URL:           https://cython.org/
 BuildRequires: rpmbuild(macros) >= 1.714
 %if %{with python2}
@@ -95,6 +96,7 @@ Pakiet zawierający przykładowe programy napisane w języku Cython.
 
 %prep
 %setup -q -n %{module}-%{version}
+%patch0 -p1
 
 %build
 %if %{with python2}
This page took 0.142362 seconds and 4 git commands to generate.