Skip to content

Commit

Permalink
Add PyList_Extend & PyList_Clear to pyo3-ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Oct 29, 2024
1 parent 0aa13c8 commit ee2f4cc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions newsfragments/4667.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `PyList_Extend` & `PyList_Clear` to pyo3-ffi
21 changes: 21 additions & 0 deletions pyo3-ffi/src/compat/py_3_13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,24 @@ compat_function!(
1
}
);

compat_function!(
originally_defined_for(Py_3_13);

#[inline]
pub unsafe fn PyList_Extend(
list: *mut crate::PyObject,
iterable: *mut crate::PyObject,
) -> std::os::raw::c_int {
crate::PyList_SetSlice(list, crate::PY_SSIZE_T_MAX, crate::PY_SSIZE_T_MAX, iterable)
}
);

compat_function!(
originally_defined_for(Py_3_13);

#[inline]
pub unsafe fn PyList_Clear(list: *mut crate::PyObject) -> std::os::raw::c_int {
crate::PyList_SetSlice(list, 0, crate::PY_SSIZE_T_MAX, std::ptr::null_mut())
}
);
4 changes: 4 additions & 0 deletions pyo3-ffi/src/listobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ extern "C" {
arg3: Py_ssize_t,
arg4: *mut PyObject,
) -> c_int;
#[cfg(Py_3_13)]
pub fn PyList_Extend(list: *mut PyObject, iterable: *mut PyObject) -> c_int;
#[cfg(Py_3_13)]
pub fn PyList_Clear(list: *mut PyObject) -> c_int;
#[cfg_attr(PyPy, link_name = "PyPyList_Sort")]
pub fn PyList_Sort(arg1: *mut PyObject) -> c_int;
#[cfg_attr(PyPy, link_name = "PyPyList_Reverse")]
Expand Down

0 comments on commit ee2f4cc

Please sign in to comment.