2772: fix PyUnicodeDecodeError_Create r=davidhewitt a=mejrs

Fixes https://github.com/PyO3/pyo3/issues/2770

Co-authored-by: mejrs <>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
This commit is contained in:
bors[bot] 2022-12-27 16:22:58 +00:00 committed by GitHub
commit 1598991a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -0,0 +1 @@
Fix `PyUnicodeDecodeError_Create` failing unconditionally with a TypeError on PyPy.

View File

@ -85,18 +85,17 @@ pub unsafe fn PyUnicodeDecodeError_Create(
length: Py_ssize_t,
start: Py_ssize_t,
end: Py_ssize_t,
_reason: *const c_char,
reason: *const c_char,
) -> *mut PyObject {
crate::PyObject_CallFunction(
PyExc_UnicodeDecodeError,
std::ffi::CStr::from_bytes_with_nul(b"sy#nns\0")
.unwrap()
.as_ptr(),
b"sy#nns\0".as_ptr().cast::<c_char>(),
encoding,
object,
length,
start,
end,
reason,
)
}