Update to 3.9.8. Fixes rhbz#2229530.

* Replace Cargo.toml patch that no longer applies with tomcli-set.
* Also remove no-panic feature.
This commit is contained in:
Maxwell G 2023-09-08 22:45:25 -05:00
commit 4e24494280
No known key found for this signature in database
GPG key ID: F79E4E25E8C661F8
5 changed files with 14 additions and 96 deletions

2
.gitignore vendored
View file

@ -3,3 +3,5 @@
/orjson-3.8.12.tar.gz
/orjson-3.8.14.tar.gz
/orjson-3.9.2.tar.gz
/orjson-3.9.7.tar.gz
/orjson-3.9.8.tar.gz

View file

@ -1,56 +0,0 @@
From c0d62d041371970297c31ac86465cf8983386191 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Sun, 23 Jul 2023 17:15:18 +0200
Subject: [PATCH] Use PyType_GetDict to safely access tp_dict [3.12]
---
src/util.rs | 15 ++++++++++++++-
test/test_default.py | 12 ++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/util.rs b/src/util.rs
index 3b451bd5..ba011c1a 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -125,7 +125,20 @@ macro_rules! str_hash {
};
}
-#[cfg(Py_3_10)]
+#[cfg(Py_3_12)]
+macro_rules! pydict_contains {
+ ($obj1:expr, $obj2:expr) => {
+ unsafe {
+ pyo3_ffi::_PyDict_Contains_KnownHash(
+ pyo3_ffi::PyType_GetDict($obj1),
+ $obj2,
+ (*$obj2.cast::<pyo3_ffi::PyASCIIObject>()).hash,
+ ) == 1
+ }
+ };
+}
+
+#[cfg(all(Py_3_10, not(Py_3_12)))]
macro_rules! pydict_contains {
($obj1:expr, $obj2:expr) => {
unsafe {
diff --git a/test/test_default.py b/test/test_default.py
index d1e95587..547fce8c 100644
--- a/test/test_default.py
+++ b/test/test_default.py
@@ -275,3 +275,15 @@ def default(obj):
orjson.dumps(ref, default=default)
assert sys.getrefcount(ref) == 2 # one for ref, one for default
+
+ def test_default_set(self):
+ """
+ dumps() default function with set
+ """
+
+ def default(obj):
+ if isinstance(obj, set):
+ return list(obj)
+ raise TypeError
+
+ assert orjson.dumps({1, 2}, default=default) == b"[1,2]"

View file

@ -1,30 +0,0 @@
From 8cb9c84fadfc490ec88665f0ab4871c2d7255738 Mon Sep 17 00:00:00 2001
From: Maxwell G <gotmax@e.email>
Date: Wed, 25 Jan 2023 20:30:13 -0600
Subject: [PATCH] Remove unstable-simd feature
This feature requires nightly Rust.
---
Cargo.toml | 6 ------
1 file changed, 6 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index fbd45a4..09724ce 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,12 +32,6 @@ crate-type = ["cdylib"]
[features]
default = []
-# Use SIMD intrinsics. This requires Rust on the nightly channel.
-unstable-simd = [
- "bytecount/generic-simd",
- "encoding_rs/simd-accel",
-]
-
# Build yyjson as a backend and panic if it fails. The default is to attempt
# to build and on failure fall back to another backend.
yyjson = []
--
2.40.1

View file

@ -8,20 +8,15 @@
%bcond tests 1
Name: python-orjson
Version: 3.9.2
Release: 2%{?dist}
Version: 3.9.8
Release: 1%{?dist}
Summary: Fast, correct Python JSON library
License: Apache-2.0 OR MIT
URL: https://github.com/ijl/orjson
Source: %{pypi_source orjson}
# Compatibility with Python 3.12
Patch: https://github.com/ijl/orjson/pull/408.patch
# Ineligble for upstreaming
Patch: Remove-unstable-simd-feature.patch
BuildRequires: tomcli
BuildRequires: python3-devel
BuildRequires: %{py3_dist pytest-forked}
BuildRequires: rust-packaging
@ -55,13 +50,17 @@ License: %{shrink:
%prep
%autosetup -p1 -n orjson-%{version}
%cargo_prep
# Remove unstable feature that requires rust nightly
tomcli-set Cargo.toml del 'features.unstable-simd'
# Remove no-panic feature
tomcli-set Cargo.toml del 'features.no-panic'
# Remove bundled rust crates
rm -r include/cargo .cargo/config.toml
# Remove bundled yyjson.
rm -rv include/yyjson/
%cargo_prep
%generate_buildrequires
@ -95,6 +94,9 @@ export RUSTFLAGS='%{build_rustflags}'
%changelog
* Tue Oct 10 2023 Maxwell G <maxwell@gtmx.me> - 3.9.8-1
- Update to 3.9.8. Fixes rhbz#2229530.
* Tue Jul 25 2023 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.9.2-2
- Backport patch to add PyType_GetDict for Python 3.12
- Fixes: rhbz#2220383

View file

@ -1 +1 @@
SHA512 (orjson-3.9.2.tar.gz) = 5ac8713c8f921f876e1c6d61daacde5d5b7a738d00f1a0c3f51df2fcb10815de0d73cc980bca43139ddd7fbfca5e800a6d31a35cc833ddb1fac7cdb181a1116f
SHA512 (orjson-3.9.8.tar.gz) = 924810c7f37debdd63398c0f4f63c0543371c227002530d19003c3f37c16a87d8d6aa93267242523d9b6e6ae94e53e6e6a84874f8eeac8ce93a3d088e8e0a4df