Merge pull request #3295 from davidhewitt/pypy-pystate

add PyState_*Module definitions for PyPy
This commit is contained in:
David Hewitt 2023-07-04 08:29:31 +00:00 committed by GitHub
commit b441e0b4ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -0,0 +1 @@
Add FFI definitions `PyState_AddModule`, `PyState_RemoveModule` and `PyState_FindModule` for PyPy 3.9 and up.

View file

@ -1,4 +1,4 @@
#[cfg(not(PyPy))]
#[cfg(any(not(PyPy), Py_3_9))]
use crate::moduleobject::PyModuleDef;
use crate::object::PyObject;
use std::os::raw::c_int;
@ -28,13 +28,17 @@ extern "C" {
#[cfg(not(PyPy))]
pub fn PyInterpreterState_GetID(arg1: *mut PyInterpreterState) -> i64;
#[cfg(not(PyPy))]
#[cfg(any(not(PyPy), Py_3_9))] // only on PyPy since 3.9
#[cfg_attr(PyPy, link_name = "PyPyState_AddModule")]
pub fn PyState_AddModule(arg1: *mut PyObject, arg2: *mut PyModuleDef) -> c_int;
#[cfg(not(PyPy))]
#[cfg(any(not(PyPy), Py_3_9))] // only on PyPy since 3.9
#[cfg_attr(PyPy, link_name = "PyPyState_RemoveModule")]
pub fn PyState_RemoveModule(arg1: *mut PyModuleDef) -> c_int;
#[cfg(not(PyPy))]
#[cfg(any(not(PyPy), Py_3_9))] // only on PyPy since 3.9
// only has PyPy prefix since 3.10
#[cfg_attr(all(PyPy, Py_3_10), link_name = "PyPyState_FindModule")]
pub fn PyState_FindModule(arg1: *mut PyModuleDef) -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "PyPyThreadState_New")]