Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PyList_Extend & PyList_Clear to pyo3-ffi #4667

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading