1
- commit a889953c08d33854e574ab06e9593e0484c4c147
2
- Author: stepan <
[email protected] >
3
- Date: Wed Jul 9 18:50:37 2025 +0200
4
-
5
- Adapt for GraalPy
6
-
7
1
diff --git a/build.rs b/build.rs
8
- index 43538c0..85857ba 100644
2
+ index 43538c0..d6394a5 100644
9
3
--- a/build.rs
10
4
+++ b/build.rs
11
- @@ -40,7 +40,8 @@ fn main() {
5
+ @@ -40,14 +40,15 @@ fn main() {
12
6
13
7
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
14
8
if is_64_bit_python {
@@ -17,7 +11,26 @@ index 43538c0..85857ba 100644
17
11
+ // println!("cargo:rustc-cfg=feature=\"inline_int\"");
18
12
}
19
13
20
- if env::var("ORJSON_DISABLE_YYJSON").is_ok() {
14
+ - if env::var("ORJSON_DISABLE_YYJSON").is_ok() {
15
+ - if env::var("CARGO_FEATURE_YYJSON").is_ok() {
16
+ - panic!("ORJSON_DISABLE_YYJSON and --features=yyjson both enabled.")
17
+ - }
18
+ - } else {
19
+ + // if env::var("ORJSON_DISABLE_YYJSON").is_ok() {
20
+ + // if env::var("CARGO_FEATURE_YYJSON").is_ok() {
21
+ + // panic!("ORJSON_DISABLE_YYJSON and --features=yyjson both enabled.")
22
+ + // }
23
+ + // } else {
24
+ match cc::Build::new()
25
+ .file("include/yyjson/yyjson.c")
26
+ .include("include/yyjson")
27
+ @@ -68,5 +69,5 @@ fn main() {
28
+ }
29
+ }
30
+ }
31
+ - }
32
+ + //}
33
+ }
21
34
diff --git a/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs b/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs
22
35
index 477ad02..0b649f3 100644
23
36
--- a/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs
@@ -484,6 +497,20 @@ index 505840e..e984191 100644
484
497
match pyobject_to_obtype(value, self.state.opts()) {
485
498
ObType::Str => {
486
499
seq.serialize_element(&StrSerializer::new(value))?;
500
+ diff --git a/src/serialize/per_type/numpy.rs b/src/serialize/per_type/numpy.rs
501
+ index f888029..4a0fe0e 100644
502
+ --- a/src/serialize/per_type/numpy.rs
503
+ +++ b/src/serialize/per_type/numpy.rs
504
+ @@ -196,8 +196,7 @@ impl NumpyArray {
505
+ pub fn new(ptr: *mut PyObject, opts: Opt) -> Result<Self, PyArrayError> {
506
+ let capsule = ffi!(PyObject_GetAttr(ptr, ARRAY_STRUCT_STR));
507
+ let array = unsafe {
508
+ - (*capsule.cast::<PyCapsule>())
509
+ - .pointer
510
+ + ffi!(PyCapsule_GetPointer(capsule, core::ptr::null_mut()))
511
+ .cast::<PyArrayInterface>()
512
+ };
513
+ if unsafe { (*array).two != 2 } {
487
514
diff --git a/src/serialize/serializer.rs b/src/serialize/serializer.rs
488
515
index 7b9a5de..e291912 100644
489
516
--- a/src/serialize/serializer.rs
@@ -769,7 +796,7 @@ index 7b1c2df..5ac8dec 100644
769
796
}
770
797
}
771
798
diff --git a/src/str/scalar.rs b/src/str/scalar.rs
772
- index 12adb63..99fce8f 100644
799
+ index 12adb63..e0cdd8b 100644
773
800
--- a/src/str/scalar.rs
774
801
+++ b/src/str/scalar.rs
775
802
@@ -1,11 +1,17 @@
@@ -790,17 +817,6 @@ index 12adb63..99fce8f 100644
790
817
let num_chars = bytecount::num_chars(buf.as_bytes());
791
818
if buf.len() == num_chars {
792
819
return pyunicode_ascii(buf.as_ptr(), num_chars);
793
- @@ -40,7 +46,9 @@ pub fn str_impl_kind_scalar(buf: &str) -> *mut pyo3_ffi::PyObject {
794
- #[inline(always)]
795
- pub fn unicode_from_str(buf: &str) -> *mut pyo3_ffi::PyObject {
796
- if unlikely!(buf.is_empty()) {
797
- - return use_immortal!(crate::typeref::EMPTY_UNICODE);
798
- + // Not immortal on GraalPy
799
- + ffi!(Py_INCREF(crate::typeref::EMPTY_UNICODE));
800
- + return unsafe { crate::typeref::EMPTY_UNICODE };
801
- }
802
- str_impl_kind_scalar(buf)
803
- }
804
820
diff --git a/src/typeref.rs b/src/typeref.rs
805
821
index bf925a4..388c9f4 100644
806
822
--- a/src/typeref.rs
@@ -851,7 +867,7 @@ index bf925a4..388c9f4 100644
851
867
ptr
852
868
}
853
869
diff --git a/src/util.rs b/src/util.rs
854
- index ccf425c..bc9268d 100644
870
+ index ccf425c..ce99eaa 100644
855
871
--- a/src/util.rs
856
872
+++ b/src/util.rs
857
873
@@ -10,7 +10,7 @@ macro_rules! is_type {
@@ -889,25 +905,35 @@ index ccf425c..bc9268d 100644
889
905
#[cfg(all(Py_3_12, not(Py_3_13)))]
890
906
macro_rules! pydict_contains {
891
907
($obj1:expr, $obj2:expr) => {
892
- @@ -222,6 +221,7 @@ macro_rules! pydict_contains {
908
+ @@ -222,18 +221,20 @@ macro_rules! pydict_contains {
893
909
unsafe { pyo3_ffi::PyDict_Contains((*$obj1).tp_dict, $obj2) == 1 }
894
910
};
895
911
}
896
912
+ */
897
913
898
- #[cfg(Py_3_12)]
899
- macro_rules! use_immortal {
900
- @@ -234,6 +234,9 @@ macro_rules! use_immortal {
914
+ - #[cfg(Py_3_12)]
915
+ - macro_rules! use_immortal {
916
+ - ($op:expr) => {
917
+ - unsafe { $op }
918
+ - };
919
+ - }
920
+ + // #[cfg(Py_3_12)]
921
+ + // macro_rules! use_immortal {
922
+ + // ($op:expr) => {
923
+ + // unsafe { $op }
924
+ + // };
925
+ + // }
926
+
927
+ - #[cfg(not(Py_3_12))]
928
+ + // #[cfg(not(Py_3_12))]
901
929
macro_rules! use_immortal {
902
930
($op:expr) => {
903
931
unsafe {
904
- + // orjson makes assumption about something being immortal that is not immortal
905
- + // on GraalPy: update the caller to do proper refcounting instead
906
- + debug_assert!(ffi!(_Py_IsImmortal($op)) == 1);
932
+ + // We let GraalPy's Py_INCREF decide what is immortal and what not
907
933
ffi!(Py_INCREF($op));
908
934
$op
909
935
}
910
- @@ -256,20 +259 ,11 @@ macro_rules! pydict_next {
936
+ @@ -256,20 +257 ,11 @@ macro_rules! pydict_next {
911
937
912
938
macro_rules! pydict_setitem {
913
939
($dict:expr, $pykey:expr, $pyval:expr) => {
0 commit comments