Skip to content

Commit

Permalink
mangle exported functions for PyPy
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Mar 9, 2023
1 parent 59bbb40 commit 8446414
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyo3-ffi/src/abstract_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern "C" {
not(PyPy),
any(Py_3_10, all(not(Py_LIMITED_API), Py_3_9)) // Added to python in 3.9 but to limited API in 3.10
))]
#[cfg_attr(PyPy, link_name = "PyPyObject_CallNoArgs")]
pub fn PyObject_CallNoArgs(func: *mut PyObject) -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "PyPyObject_Call")]
pub fn PyObject_Call(
Expand Down Expand Up @@ -113,6 +114,7 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyIter_Next")]
pub fn PyIter_Next(arg1: *mut PyObject) -> *mut PyObject;
#[cfg(all(not(PyPy), Py_3_10))]
#[cfg_attr(PyPy, link_name = "PyPyIter_Send")]
pub fn PyIter_Send(iter: *mut PyObject, arg: *mut PyObject, presult: *mut *mut PyObject);

#[cfg_attr(PyPy, link_name = "PyPyNumber_Check")]
Expand Down
1 change: 1 addition & 0 deletions pyo3-ffi/src/modsupport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extern "C" {
// skipped non-limited _PyArg_Fini

#[cfg(Py_3_10)]
#[cfg_attr(PyPy, link_name = "PyPyModule_AddObjectRef")]
pub fn PyModule_AddObjectRef(
module: *mut PyObject,
name: *const c_char,
Expand Down
3 changes: 3 additions & 0 deletions pyo3-ffi/src/objimpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ extern "C" {
pub fn PyGC_Collect() -> Py_ssize_t;

#[cfg(Py_3_10)]
#[cfg_attr(PyPy, link_name = "PyPyGC_Enable")]
pub fn PyGC_Enable() -> c_int;

#[cfg(Py_3_10)]
#[cfg_attr(PyPy, link_name = "PyPyGC_Disable")]
pub fn PyGC_Disable() -> c_int;

#[cfg(Py_3_10)]
#[cfg_attr(PyPy, link_name = "PyPyGC_IsEnabled")]
pub fn PyGC_IsEnabled() -> c_int;
}

Expand Down
5 changes: 5 additions & 0 deletions pyo3-ffi/src/pyerrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyExc_ResourceWarning")]
pub static mut PyExc_ResourceWarning: *mut PyObject;
#[cfg(Py_3_10)]
#[cfg_attr(PyPy, link_name = "PyPyExc_EncodingWarning")]
pub static mut PyExc_EncodingWarning: *mut PyObject;
}

Expand Down Expand Up @@ -305,9 +306,13 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyErr_SetInterrupt")]
pub fn PyErr_SetInterrupt();
#[cfg(Py_3_10)]
#[cfg_attr(PyPy, link_name = "PyPyErr_SetInterruptEx")]
pub fn PyErr_SetInterruptEx(signum: c_int);
#[cfg_attr(PyPy, link_name = "PyPyErr_SyntaxLocation")]
pub fn PyErr_SyntaxLocation(filename: *const c_char, lineno: c_int);
#[cfg_attr(PyPy, link_name = "PyPyErr_SyntaxLocationEx")]
pub fn PyErr_SyntaxLocationEx(filename: *const c_char, lineno: c_int, col_offset: c_int);
#[cfg_attr(PyPy, link_name = "PyPyErr_ProgramText")]
pub fn PyErr_ProgramText(filename: *const c_char, lineno: c_int) -> *mut PyObject;
#[cfg(not(PyPy))]
pub fn PyUnicodeDecodeError_Create(
Expand Down

0 comments on commit 8446414

Please sign in to comment.