PyO3 32-bit fix is now included in upstream Python 3.14 PR

This commit is contained in:
Benjamin A. Beasley 2025-06-05 08:01:25 -04:00
commit 6177d02f00
3 changed files with 60 additions and 42 deletions

View file

@ -1,27 +0,0 @@
From c42f6b171f1be6961c7f599405a29147862642b7 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Wed, 4 Jun 2025 08:58:27 -0400
Subject: [PATCH] Make PyObjectObRefcnt.refcnt_and_flags 64-bit-only
Fix #5175 as described in
https://github.com/PyO3/pyo3/issues/5175#issuecomment-2939918138.
---
include/pyo3/pyo3-ffi/src/object.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/pyo3/pyo3-ffi/src/object.rs b/include/pyo3/pyo3-ffi/src/object.rs
index 5fbf45d..aeb9735 100644
--- a/include/pyo3/pyo3-ffi/src/object.rs
+++ b/include/pyo3/pyo3-ffi/src/object.rs
@@ -49,7 +49,7 @@ pub struct PyObjectObFlagsAndRefcnt {
pub union PyObjectObRefcnt {
#[cfg(all(target_pointer_width = "64", Py_3_14))]
pub ob_refcnt_full: crate::PY_INT64_T,
- #[cfg(Py_3_14)]
+ #[cfg(all(target_pointer_width = "64", Py_3_14))]
pub refcnt_and_flags: PyObjectObFlagsAndRefcnt,
pub ob_refcnt: Py_ssize_t,
#[cfg(all(target_pointer_width = "64", not(Py_3_14)))]
--
2.49.0

View file

@ -1,7 +1,7 @@
From 180f5886407e7c1dda34afa6fc7298b34d2925da Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Fri, 23 May 2025 15:02:33 +0200
Subject: [PATCH 1/6] Update pyo3 to 0.25.0
Subject: [PATCH 1/8] Update pyo3 to 0.25.0
---
Cargo.lock | 4 +-
@ -3525,7 +3525,7 @@ index 305dc290..88a1bf90 100644
From d2570d2f25eba771468f41020a2ad69e0cbdbbc7 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Fri, 23 May 2025 17:00:34 +0200
Subject: [PATCH 2/6] Add pyo3-ffi patch for _PyLong_AsByteArray with
Subject: [PATCH 2/8] Add pyo3-ffi patch for _PyLong_AsByteArray with
exceptions
Co-authored-by: ijl <ijl@mailbox.org>
@ -3567,7 +3567,7 @@ index 00000000..20e5d7a3
From d01aea4541800dca412e3f4c3068e974f18c3218 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Fri, 23 May 2025 18:26:19 +0200
Subject: [PATCH 3/6] Apply pyo3-ffi patch
Subject: [PATCH 3/8] Apply pyo3-ffi patch
---
include/pyo3/pyo3-ffi/src/cpython/longobject.rs | 12 ++++++++++++
@ -3600,7 +3600,7 @@ index 45acaae5..6063575e 100644
From 6427dba13406b499bc2edc033c0eeeaafdfa4ad4 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Fri, 23 May 2025 15:16:24 +0200
Subject: [PATCH 4/6] Fix _PyDict_SetItem_KnownHash_LockHeld
Subject: [PATCH 4/8] Fix _PyDict_SetItem_KnownHash_LockHeld
---
src/util.rs | 10 ----------
@ -3634,7 +3634,7 @@ index ccf425ce..0a255c3f 100644
From 80779519c9363a81884e77358e62fb443a584039 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Fri, 23 May 2025 15:16:40 +0200
Subject: [PATCH 5/6] Fix _Py_IsImmortal
Subject: [PATCH 5/8] Fix _Py_IsImmortal
---
src/util.rs | 6 ++----
@ -3661,7 +3661,7 @@ index 0a255c3f..bbfb72ed 100644
From b90995f44f80176d403b720d706dfe5a027855ff Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Fri, 23 May 2025 17:12:44 +0200
Subject: [PATCH 6/6] Use PyUnicode API
Subject: [PATCH 6/8] Use PyUnicode API
---
src/serialize/per_type/dict.rs | 4 ++--
@ -3800,3 +3800,57 @@ index 7b1c2df2..738b8489 100644
debug_assert!((*(ptr.cast::<PyASCIIObject>())).ascii() == 1);
validate_str!(ptr);
ptr.cast::<PyObject>()
From 4eb6604607891c0f6aa00bbbb07ccfdcfd85b589 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Thu, 5 Jun 2025 13:52:28 +0200
Subject: [PATCH 7/8] Add pyo3-ffi patch for PyObjectObRefcnt.refcnt_and_flags
Co-authored-by: Benjamin A. Beasley <code@musicinmybrain.net>
---
include/pyo3-ffi-pyobjectrefcnt-64only.patch | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 include/pyo3-ffi-pyobjectrefcnt-64only.patch
diff --git a/include/pyo3-ffi-pyobjectrefcnt-64only.patch b/include/pyo3-ffi-pyobjectrefcnt-64only.patch
new file mode 100644
index 00000000..dfc328a7
--- /dev/null
+++ b/include/pyo3-ffi-pyobjectrefcnt-64only.patch
@@ -0,0 +1,13 @@
+diff --git a/include/pyo3/pyo3-ffi/src/object.rs b/include/pyo3/pyo3-ffi/src/object.rs
+index c4c5abc361c..6d5dc781287 100644
+--- a/include/pyo3/pyo3-ffi/src/object.rs
++++ b/include/pyo3/pyo3-ffi/src/object.rs
+@@ -49,7 +49,7 @@ pub struct PyObjectObFlagsAndRefcnt {
+ pub union PyObjectObRefcnt {
+ #[cfg(all(target_pointer_width = "64", Py_3_14))]
+ pub ob_refcnt_full: crate::PY_INT64_T,
+- #[cfg(Py_3_14)]
++ #[cfg(all(target_pointer_width = "64", Py_3_14))]
+ pub refcnt_and_flags: PyObjectObFlagsAndRefcnt,
+ pub ob_refcnt: Py_ssize_t,
+ #[cfg(all(target_pointer_width = "64", not(Py_3_14)))]
From ea5a7d83f4ff5262f131d37dd1d490a634ce2626 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Thu, 5 Jun 2025 13:54:27 +0200
Subject: [PATCH 8/8] Apply second pyo3-ffi patch
---
include/pyo3/pyo3-ffi/src/object.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/pyo3/pyo3-ffi/src/object.rs b/include/pyo3/pyo3-ffi/src/object.rs
index 5fbf45db..aeb97352 100644
--- a/include/pyo3/pyo3-ffi/src/object.rs
+++ b/include/pyo3/pyo3-ffi/src/object.rs
@@ -49,7 +49,7 @@ pub struct PyObjectObFlagsAndRefcnt {
pub union PyObjectObRefcnt {
#[cfg(all(target_pointer_width = "64", Py_3_14))]
pub ob_refcnt_full: crate::PY_INT64_T,
- #[cfg(Py_3_14)]
+ #[cfg(all(target_pointer_width = "64", Py_3_14))]
pub refcnt_and_flags: PyObjectObFlagsAndRefcnt,
pub ob_refcnt: Py_ssize_t,
#[cfg(all(target_pointer_width = "64", not(Py_3_14)))]

View file

@ -20,15 +20,6 @@ Source: %{pypi_source orjson}
# Support Python 3.14
# Updates bundled/forked pyo3-build-config/pyo3-ffi to 0.25.0
Patch: https://github.com/ijl/orjson/pull/570.patch
# Cherry-pick pyo3-ffi fix for Python 3.14 i686 segfaults:
#
# Make PyObjectObRefcnt.refcnt_and_flags 64-bit-only
# https://github.com/PyO3/pyo3/pull/5180
#
# Cherry-picked on top of https://github.com/ijl/orjson/pull/570 (without the
# commit adding a news fragment); see
# https://github.com/ijl/orjson/pull/570#issuecomment-2943844083.
Patch: 0001-Make-PyObjectObRefcnt.refcnt_and_flags-64-bit-only.patch
BuildRequires: tomcli
BuildRequires: python3-devel