Skip to content

Commit

Permalink
Merge #2772
Browse files Browse the repository at this point in the history
2772: fix PyUnicodeDecodeError_Create r=davidhewitt a=mejrs

Fixes #2770

Co-authored-by: mejrs <>
Co-authored-by: David Hewitt <[email protected]>
  • Loading branch information
bors[bot] and davidhewitt authored Dec 27, 2022
2 parents 14d61e6 + 5fcc874 commit 1598991
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions newsfragments/2772.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `PyUnicodeDecodeError_Create` failing unconditionally with a TypeError on PyPy.
7 changes: 3 additions & 4 deletions pyo3-ffi/src/pyerrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}

Expand Down

0 comments on commit 1598991

Please sign in to comment.