Adapt to changed function name in Python 3.13

As requested in https://bugzilla.redhat.com/show_bug.cgi?id=2245864#c1
This commit is contained in:
Miro Hrončok 2023-10-27 11:21:22 +02:00
parent 9a9939bec9
commit 4ec630b464
2 changed files with 36 additions and 0 deletions

32
4902.patch Normal file
View File

@ -0,0 +1,32 @@
From 4fb75b73c902deae5a4805bb9e4ea6451952183e Mon Sep 17 00:00:00 2001
From: Mattias Ellert <mattias.ellert@physics.uu.se>
Date: Tue, 24 Oct 2023 15:59:02 +0200
Subject: [PATCH] Adapt to changed function name in Python 3.13
According to https://docs.python.org/3.13/whatsnew/3.13.html:
Add PyThreadState_GetUnchecked() function: similar to
PyThreadState_Get(), but don't kill the process with a fatal error if
it is NULL. The caller is responsible to check if the result is
NULL. Previously, the function was private and known as
_PyThreadState_UncheckedGet().
---
include/pybind11/detail/type_caster_base.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h
index fc5f1c88b3..68512b5bd0 100644
--- a/include/pybind11/detail/type_caster_base.h
+++ b/include/pybind11/detail/type_caster_base.h
@@ -486,8 +486,10 @@ PYBIND11_NOINLINE handle get_object_handle(const void *ptr, const detail::type_i
inline PyThreadState *get_thread_state_unchecked() {
#if defined(PYPY_VERSION)
return PyThreadState_GET();
-#else
+#elif PY_VERSION_HEX < 0x030D0000
return _PyThreadState_UncheckedGet();
+#else
+ return PyThreadState_GetUnchecked();
#endif
}

View File

@ -26,6 +26,9 @@ Source0: https://github.com/pybind/pybind11/archive/v%{version}/%{name}-%{versio
# Patch out header path
Patch1: pybind11-2.10.1-hpath.patch
# Adapt to changed function name in Python 3.13
Patch2: https://github.com/pybind/pybind11/pull/4902.patch
BuildRequires: make
%if %{python2_enabled}
# Needed to build the python libraries
@ -108,6 +111,7 @@ This package contains the Python 3 files.
%prep
%setup -q
%patch1 -p1 -b .hpath
%patch2 -p1 -b .4902
%build
pys=""