pyo3_ffi/compat/
py_3_13.rscompat_function!(
originally_defined_for(Py_3_13);
#[inline]
pub unsafe fn PyDict_GetItemRef(
dp: *mut crate::PyObject,
key: *mut crate::PyObject,
result: *mut *mut crate::PyObject,
) -> std::os::raw::c_int {
use crate::{compat::Py_NewRef, PyDict_GetItemWithError, PyErr_Occurred};
let item = PyDict_GetItemWithError(dp, key);
if !item.is_null() {
*result = Py_NewRef(item);
return 1; }
*result = std::ptr::null_mut();
if PyErr_Occurred().is_null() {
return 0; }
-1
}
);
compat_function!(
originally_defined_for(Py_3_13);
#[inline]
pub unsafe fn PyList_GetItemRef(
arg1: *mut crate::PyObject,
arg2: crate::Py_ssize_t,
) -> *mut crate::PyObject {
use crate::{PyList_GetItem, Py_XINCREF};
let item = PyList_GetItem(arg1, arg2);
Py_XINCREF(item);
item
}
);
compat_function!(
originally_defined_for(Py_3_13);
#[inline]
pub unsafe fn PyWeakref_GetRef(
reference: *mut crate::PyObject,
pobj: *mut *mut crate::PyObject,
) -> std::os::raw::c_int {
use crate::{
compat::Py_NewRef, PyErr_SetString, PyExc_TypeError, PyWeakref_Check,
PyWeakref_GetObject, Py_None,
};
if !reference.is_null() && PyWeakref_Check(reference) == 0 {
*pobj = std::ptr::null_mut();
PyErr_SetString(PyExc_TypeError, c_str!("expected a weakref").as_ptr());
return -1;
}
let obj = PyWeakref_GetObject(reference);
if obj.is_null() {
*pobj = std::ptr::null_mut();
return -1;
}
if obj == Py_None() {
*pobj = std::ptr::null_mut();
return 0;
}
*pobj = Py_NewRef(obj);
1
}
);