-
Notifications
You must be signed in to change notification settings - Fork 782
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
ffi: define compat for Py_NewRef
and Py_XNewRef
#4445
Conversation
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I think we should add a test to ensure glob re-exports do not trigger import ambiguity:
mod test_export{
pub use pyo3_ffi::compat::*;
pub use pyo3_ffi::*;
}
Great idea. It turned out to be a little bit harder than just that pair of |
* ffi: define compat for `Py_NewRef` and `Py_XNewRef` * add missing inline hint Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com> * don't use std::ffi::c_int (requires MSRV 1.64) * add test to guard against ambiguity --------- Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
* ffi: define compat for `Py_NewRef` and `Py_XNewRef` * add missing inline hint Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com> * don't use std::ffi::c_int (requires MSRV 1.64) * add test to guard against ambiguity * fix `Py_NewRef` cfg on PyPy --------- Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
* ffi: define compat for `Py_NewRef` and `Py_XNewRef` * add missing inline hint Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com> * don't use std::ffi::c_int (requires MSRV 1.64) * add test to guard against ambiguity * fix `Py_NewRef` cfg on PyPy --------- Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
* ffi: define compat for `Py_NewRef` and `Py_XNewRef` * add missing inline hint Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com> * don't use std::ffi::c_int (requires MSRV 1.64) * add test to guard against ambiguity * fix `Py_NewRef` cfg on PyPy --------- Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
This improves the FFI definitions
Py_NewRef
andPy_XNewRef
in the following ways:#[doc(cfg(Py_3_10))]
to the original definitions (which are either an extern symbol or an inline function depending on abi3 setting, and so would a cfg hint in the doc saying they were only available in one of these)Py_NewRef
andPy_XNewRef
topyo3_ffi::compat
, so we can use them on all versions internally_Py_NewRef
and_Py_XNewRef
To make the doc-cfgs on
pyo3_ffi::compat
work properly, I realised that I needed to use functions rather than re-exports when running thedocrs
build. I decided to use a macro to make this implementation easier. This way thecompat
functions are identical regardless of what Python version we build with. (cc @mejrs)This is what I saw before (clicking on these re-exports then shows a version cfg):
After: