ffi: add missing definition PyCMethod_New
This commit is contained in:
parent
f3df59c76b
commit
b84309b67d
|
@ -91,6 +91,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Use the Rust function path for `wrap_pymodule!` of a `#[pymodule]` with a `#[pyo3(name = "..")]` attribute, not the Python name. [#2081](https://github.com/PyO3/pyo3/pull/2081)
|
||||
- Fix panic in `#[pyfunction]` generated code when a required argument following an `Option` was not provided. [#2093](https://github.com/PyO3/pyo3/pull/2093)
|
||||
- Fixed undefined behaviour caused by incorrect `ExactSizeIterator` implementations. [#2124](https://github.com/PyO3/pyo3/pull/2124)
|
||||
- Fix missing FFI definition `PyCMethod_New` on Python 3.9 and up. [#2143](https://github.com/PyO3/pyo3/pull/2143)
|
||||
- Add missing FFI definitions `_PyLong_NumBits` and `_PyLong_AsByteArray` on PyPy. [#2146](https://github.com/PyO3/pyo3/pull/2146)
|
||||
- Fix memory leak in implementation of `AsPyPointer` for `Option<T>`. [#2160](https://github.com/PyO3/pyo3/pull/2160)
|
||||
- Fix the signature of `_PyLong_NumBits` [#2161](https://github.com/PyO3/pyo3/pull/2161)
|
||||
|
|
|
@ -117,6 +117,7 @@ pub union PyMethodDefPointer {
|
|||
const _: () =
|
||||
[()][mem::size_of::<PyMethodDefPointer>() - mem::size_of::<Option<extern "C" fn()>>()];
|
||||
|
||||
#[cfg(not(Py_3_9))]
|
||||
extern "C" {
|
||||
#[cfg_attr(PyPy, link_name = "PyPyCFunction_New")]
|
||||
pub fn PyCFunction_New(ml: *mut PyMethodDef, slf: *mut PyObject) -> *mut PyObject;
|
||||
|
@ -129,7 +130,32 @@ extern "C" {
|
|||
) -> *mut PyObject;
|
||||
}
|
||||
|
||||
// skipped non-limited / 3.9 PyCMethod_New
|
||||
#[cfg(Py_3_9)]
|
||||
#[inline]
|
||||
pub unsafe fn PyCFunction_New(ml: *mut PyMethodDef, slf: *mut PyObject) -> *mut PyObject {
|
||||
PyCFunction_NewEx(ml, slf, std::ptr::null_mut())
|
||||
}
|
||||
|
||||
#[cfg(Py_3_9)]
|
||||
#[inline]
|
||||
pub unsafe fn PyCFunction_NewEx(
|
||||
ml: *mut PyMethodDef,
|
||||
slf: *mut PyObject,
|
||||
module: *mut PyObject,
|
||||
) -> *mut PyObject {
|
||||
PyCMethod_New(ml, slf, module, std::ptr::null_mut())
|
||||
}
|
||||
|
||||
#[cfg(Py_3_9)]
|
||||
extern "C" {
|
||||
#[cfg_attr(PyPy, link_name = "PyPyCMethod_New")]
|
||||
pub fn PyCMethod_New(
|
||||
ml: *mut PyMethodDef,
|
||||
slf: *mut PyObject,
|
||||
module: *mut PyObject,
|
||||
cls: *mut PyTypeObject,
|
||||
) -> *mut PyObject;
|
||||
}
|
||||
|
||||
/* Flag passed to newmethodobject */
|
||||
pub const METH_VARARGS: c_int = 0x0001;
|
||||
|
|
Loading…
Reference in New Issue