Skip to content

Commit d5304a2

Browse files
committed
[GR-67434] Update patch for orjson 3.10.18.
PullRequest: graalpython/3927
2 parents 7f099a6 + 8e1603b commit d5304a2

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_pystate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,19 @@ def test_SetAsyncExc(self):
9191
import threading
9292
start = threading.Barrier(2, timeout=20)
9393

94-
caught_ex = None
94+
caught_ex = "initial value of caught_ex"
9595
def other_thread():
96+
nonlocal caught_ex
9697
try:
9798
start.wait() # ensure we are in the try, before raising
9899
r = 0
99100
for i in range(1, 1000000000):
100101
for j in range(i, 1000000000):
101102
r += j / i
102103
except Exception as e:
103-
nonlocal caught_ex
104104
caught_ex = e
105+
else:
106+
caught_ex = "no exception caught"
105107

106108

107109
t = threading.Thread(target=other_thread)
@@ -111,4 +113,4 @@ def other_thread():
111113
SetAsyncExcCaller.trigger_ex(t.ident, Exception("test my message"))
112114
t.join()
113115

114-
assert "test my message" in str(caught_ex), str(caught_ex)
116+
assert "test my message" in str(caught_ex), f"{str(caught_ex)=}, {t.is_alive()=}"

graalpython/lib-graalpython/patches/orjson-3.10.18.patch

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
commit 121a88e014aba626f45c72baed02b32c7b125f07
1+
commit a889953c08d33854e574ab06e9593e0484c4c147
22
Author: stepan <[email protected]>
33
Date: Wed Jul 9 18:50:37 2025 +0200
44

@@ -683,7 +683,7 @@ index 4f1c76b..3d2c7e9 100644
683683
}
684684
}
685685
diff --git a/src/str/pyunicode_new.rs b/src/str/pyunicode_new.rs
686-
index 7b1c2df..0f21024 100644
686+
index 7b1c2df..5ac8dec 100644
687687
--- a/src/str/pyunicode_new.rs
688688
+++ b/src/str/pyunicode_new.rs
689689
@@ -1,75 +1,30 @@
@@ -765,14 +765,32 @@ index 7b1c2df..0f21024 100644
765765
- core::ptr::write(data_ptr, 0);
766766
- validate_str!(ptr);
767767
- ptr.cast::<PyObject>()
768-
+ PyUnicode_FromStringAndSize(buf.as_ptr() as *const i8, usize_to_isize(num_chars))
768+
+ PyUnicode_FromStringAndSize(buf.as_ptr() as *const i8, usize_to_isize(buf.len()))
769769
}
770770
}
771771
diff --git a/src/str/scalar.rs b/src/str/scalar.rs
772-
index 12adb63..c8e6a2e 100644
772+
index 12adb63..99fce8f 100644
773773
--- a/src/str/scalar.rs
774774
+++ b/src/str/scalar.rs
775-
@@ -40,7 +40,9 @@ pub fn str_impl_kind_scalar(buf: &str) -> *mut pyo3_ffi::PyObject {
775+
@@ -1,11 +1,17 @@
776+
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
777+
778+
+use pyo3_ffi::PyUnicode_FromStringAndSize;
779+
use crate::str::pyunicode_new::{
780+
pyunicode_ascii, pyunicode_fourbyte, pyunicode_onebyte, pyunicode_twobyte,
781+
};
782+
+use crate::util::usize_to_isize;
783+
784+
#[inline(never)]
785+
pub fn str_impl_kind_scalar(buf: &str) -> *mut pyo3_ffi::PyObject {
786+
+ // all the optimizations below don't make sense for GraalPy
787+
+ return unsafe {
788+
+ PyUnicode_FromStringAndSize(buf.as_ptr() as *const i8, usize_to_isize(buf.len()))
789+
+ };
790+
let num_chars = bytecount::num_chars(buf.as_bytes());
791+
if buf.len() == num_chars {
792+
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 {
776794
#[inline(always)]
777795
pub fn unicode_from_str(buf: &str) -> *mut pyo3_ffi::PyObject {
778796
if unlikely!(buf.is_empty()) {

0 commit comments

Comments
 (0)