fix `SystemError` raised from `PyUnicodeDecodeError_Create` on PyPy 3.10

This commit is contained in:
David Hewitt 2023-07-05 11:10:02 +01:00
parent 54ab9090be
commit 82712aed32
4 changed files with 18 additions and 3 deletions

View File

@ -0,0 +1 @@
Add FFI definitions `_PyObject_CallFunction_SizeT` and `_PyObject_CallMethod_SizeT`.

View File

@ -0,0 +1 @@
Fix `SystemError` raised in `PyUnicodeDecodeError_Create` on PyPy 3.10.

View File

@ -52,8 +52,21 @@ extern "C" {
... ...
) -> *mut PyObject; ) -> *mut PyObject;
// skipped _PyObject_CallFunction_SizeT #[cfg(not(Py_3_13))]
// skipped _PyObject_CallMethod_SizeT #[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")] #[cfg_attr(PyPy, link_name = "PyPyObject_CallFunctionObjArgs")]
pub fn PyObject_CallFunctionObjArgs(callable: *mut PyObject, ...) -> *mut PyObject; pub fn PyObject_CallFunctionObjArgs(callable: *mut PyObject, ...) -> *mut PyObject;

View File

@ -99,7 +99,7 @@ pub unsafe fn PyUnicodeDecodeError_Create(
end: Py_ssize_t, end: Py_ssize_t,
reason: *const c_char, reason: *const c_char,
) -> *mut PyObject { ) -> *mut PyObject {
crate::PyObject_CallFunction( crate::_PyObject_CallFunction_SizeT(
PyExc_UnicodeDecodeError, PyExc_UnicodeDecodeError,
b"sy#nns\0".as_ptr().cast::<c_char>(), b"sy#nns\0".as_ptr().cast::<c_char>(),
encoding, encoding,