Skip to content

Commit

Permalink
ffi: PyPy and Python 3.10 attributes for unicodeobject
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt authored and indygreg committed Aug 14, 2021
1 parent 9690e9e commit ac8ca9b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ffi/cpython/unicodeobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,15 @@ pub unsafe fn PyUnicode_READY(op: *mut PyObject) -> c_int {
// skipped PyUnicode_WSTR_LENGTH

extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyUnicode_New")]
pub fn PyUnicode_New(size: Py_ssize_t, maxchar: Py_UCS4) -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "_PyPyUnicode_Ready")]
pub fn _PyUnicode_Ready(unicode: *mut PyObject) -> c_int;

// skipped _PyUnicode_Copy

#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyUnicode_CopyCharacters(
to: *mut PyObject,
to_start: Py_ssize_t,
Expand All @@ -243,6 +247,8 @@ extern "C" {

// skipped _PyUnicode_FastCopyCharacters

#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyUnicode_Fill(
unicode: *mut PyObject,
start: Py_ssize_t,
Expand All @@ -257,6 +263,7 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyUnicode_FromUnicode")]
pub fn PyUnicode_FromUnicode(u: *const Py_UNICODE, size: Py_ssize_t) -> *mut PyObject;

#[cfg_attr(PyPy, link_name = "PyPyUnicode_FromKindAndData")]
pub fn PyUnicode_FromKindAndData(
kind: c_int,
buffer: *const c_void,
Expand Down Expand Up @@ -551,6 +558,7 @@ mod tests {

// This has potential to mutate object. But it should be a no-op since
// we're already ready.
#[cfg_attr(Py_3_10, allow(deprecated))]
assert_eq!(PyUnicode_READY(ptr), 0);
}
})
Expand Down Expand Up @@ -589,6 +597,7 @@ mod tests {

// This has potential to mutate object. But it should be a no-op since
// we're already ready.
#[cfg_attr(Py_3_10, allow(deprecated))]
assert_eq!(PyUnicode_READY(ptr), 0);
}
})
Expand Down

0 comments on commit ac8ca9b

Please sign in to comment.