[packages/python-Cython] - added gc-py2-fix backported from git (fixes python2 crash in generated deallocation code); release
qboosh
qboosh at pld-linux.org
Sat Sep 23 21:27:57 CEST 2023
commit 5a0fc37a3ff682e1a78efd3e48ff8e756cc3a94e
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Sat Sep 23 21:17:21 2023 +0200
- added gc-py2-fix backported from git (fixes python2 crash in generated deallocation code); release 2
cython-gc-py2-fix.patch | 28 ++++++++++++++++++++++++++++
python-Cython.spec | 4 +++-
2 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/python-Cython.spec b/python-Cython.spec
index 5308128..4b8587b 100644
--- a/python-Cython.spec
+++ b/python-Cython.spec
@@ -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}
diff --git a/cython-gc-py2-fix.patch b/cython-gc-py2-fix.patch
new file mode 100644
index 0000000..e11d0b3
--- /dev/null
+++ b/cython-gc-py2-fix.patch
@@ -0,0 +1,28 @@
+From 039ef7c6242b3b6a18363ff22ead04f4e7cce676 Mon Sep 17 00:00:00 2001
+From: Stefan Behnel <stefan_ml at 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:
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python-Cython.git/commitdiff/5a0fc37a3ff682e1a78efd3e48ff8e756cc3a94e
More information about the pld-cvs-commit
mailing list