Skip to content

Commit

Permalink
Add patch for jiter
Browse files Browse the repository at this point in the history
Fixes #418
  • Loading branch information
msimacek committed Aug 26, 2024
1 parent 3e1766e commit 19a7eef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions graalpython/lib-graalpython/patches/jiter/jiter.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/crates/jiter/src/py_string_cache.rs b/crates/jiter/src/py_string_cache.rs
index 96dcf66..21e6979 100644
--- a/crates/jiter/src/py_string_cache.rs
+++ b/crates/jiter/src/py_string_cache.rs
@@ -200,7 +200,7 @@ pub fn pystring_fast_new<'py>(py: Python<'py>, s: &str, ascii_only: bool) -> Bou

/// Faster creation of PyString from an ASCII string, inspired by
/// https://github.com/ijl/orjson/blob/3.10.0/src/str/create.rs#L41
-#[cfg(not(PyPy))]
+#[cfg(all(not(PyPy), not(GraalPy)))]
unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
let ptr = pyo3::ffi::PyUnicode_New(s.len() as isize, 127);
// see https://github.com/pydantic/jiter/pull/72#discussion_r1545485907
@@ -212,7 +212,7 @@ unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyStri
}

// ffi::PyUnicode_DATA seems to be broken for pypy, hence this, marked as unsafe to avoid warnings
-#[cfg(PyPy)]
+#[cfg(any(PyPy, GraalPy))]
unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
PyString::new_bound(py, s)
}
3 changes: 3 additions & 0 deletions graalpython/lib-graalpython/patches/jiter/metadata.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[rules]]
patch = 'jiter.patch'
license = 'MIT'

0 comments on commit 19a7eef

Please sign in to comment.