Skip to content

Commit

Permalink
Merge pull request #3297 from davidhewitt/pypy-ssize-t
Browse files Browse the repository at this point in the history
fix `SystemError` raised from `PyUnicodeDecodeError_Create` on PyPy 3.10
  • Loading branch information
davidhewitt authored Jul 5, 2023
2 parents edb62e0 + 82712ae commit 8fcf444
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions newsfragments/3297.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add FFI definitions `_PyObject_CallFunction_SizeT` and `_PyObject_CallMethod_SizeT`.
1 change: 1 addition & 0 deletions newsfragments/3297.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `SystemError` raised in `PyUnicodeDecodeError_Create` on PyPy 3.10.
17 changes: 15 additions & 2 deletions pyo3-ffi/src/abstract_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,21 @@ extern "C" {
...
) -> *mut PyObject;

// skipped _PyObject_CallFunction_SizeT
// skipped _PyObject_CallMethod_SizeT
#[cfg(not(Py_3_13))]
#[cfg_attr(PyPy, link_name = "_PyPyObject_CallFunction_SizeT")]
pub fn _PyObject_CallFunction_SizeT(
callable_object: *mut PyObject,
format: *const c_char,
...
) -> *mut PyObject;
#[cfg(not(Py_3_13))]
#[cfg_attr(PyPy, link_name = "_PyPyObject_CallMethod_SizeT")]
pub fn _PyObject_CallMethod_SizeT(
o: *mut PyObject,
method: *const c_char,
format: *const c_char,
...
) -> *mut PyObject;

#[cfg_attr(PyPy, link_name = "PyPyObject_CallFunctionObjArgs")]
pub fn PyObject_CallFunctionObjArgs(callable: *mut PyObject, ...) -> *mut PyObject;
Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/src/pyerrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub unsafe fn PyUnicodeDecodeError_Create(
end: Py_ssize_t,
reason: *const c_char,
) -> *mut PyObject {
crate::PyObject_CallFunction(
crate::_PyObject_CallFunction_SizeT(
PyExc_UnicodeDecodeError,
b"sy#nns\0".as_ptr().cast::<c_char>(),
encoding,
Expand Down

0 comments on commit 8fcf444

Please sign in to comment.