Backport compile-time Python 3.12 compatibility for CYTHON_TRACE support

This commit is contained in:
Petr Viktorin 2023-06-30 16:52:02 +02:00
parent 5bbbb81a09
commit c6b945e9de
2 changed files with 52 additions and 1 deletions

View File

@ -9,7 +9,7 @@
Name: Cython
Version: 0.29.35
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Language for writing Python extension modules
License: Apache-2.0
@ -21,6 +21,11 @@ Source: https://github.com/cython/cython/archive/%{version}/Cython-%{ver
# Fixes https://bugzilla.redhat.com/2155090
Patch: emacs-docstring-wrap.patch
# Compile-time Python 3.12 compatibility for CYTHON_TRACE support
# Taken from the 3.x branch upstream.
# See: https://github.com/cython/cython/issues/5450
Patch: https://github.com/cython/cython/commit/03c498d3142ccee2da258c540e96f12c863159fc.patch?/py3.12-tracing.patch
BuildRequires: python3-devel
BuildRequires: python3-setuptools
@ -151,6 +156,9 @@ cp -p cython-mode-init.el cython-mode-init.elc %{buildroot}%{_emacs_sitestartdir
%changelog
* Fri Jun 30 2023 Petr Viktorin <pviktori@redhat.com> - 0.29.35-2
- Compile-time Python 3.12 compatibility for CYTHON_TRACE support
* Sun Jun 18 2023 Miro Hrončok <mhroncok@redhat.com> - 0.29.35-1
- Update to 0.29.35
- Fixes: rhbz#2210064

43
py3.12-tracing.patch Normal file
View File

@ -0,0 +1,43 @@
From 03c498d3142ccee2da258c540e96f12c863159fc Mon Sep 17 00:00:00 2001
From: Stefan Behnel <stefan_ml@behnel.de>
Date: Mon, 29 May 2023 22:08:50 +0200
Subject: [PATCH] Avoid using the thread state attribute "use_tracing" in
Python 3.12 where it was removed from the struct.
See PEP-669 (https://peps.python.org/pep-0669/) and the implementation in https://github.com/python/cpython/pull/103083.
There is more to be done to properly support PEP-669, but this makes it compile.
See https://github.com/cython/cython/issues/5450
---
Cython/Utility/Profile.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/Cython/Utility/Profile.c b/Cython/Utility/Profile.c
index 20b599e7979..2b8564b226f 100644
--- a/Cython/Utility/Profile.c
+++ b/Cython/Utility/Profile.c
@@ -61,15 +61,21 @@
#define __Pyx_TraceFrameInit(codeobj) \
if (codeobj) $frame_code_cname = (PyCodeObject*) codeobj;
+
#if PY_VERSION_HEX >= 0x030b00a2
+ #if PY_VERSION_HEX >= 0x030C00b1
+ #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \
+ ((!(check_tracing) || !(tstate)->tracing) && \
+ (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc)))
+ #else
#define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \
(unlikely((tstate)->cframe->use_tracing) && \
(!(check_tracing) || !(tstate)->tracing) && \
(!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc)))
+ #endif
- #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate)
-
- #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate)
+ #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate)
+ #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate)
#elif PY_VERSION_HEX >= 0x030a00b1
#define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \