-
Notifications
You must be signed in to change notification settings - Fork 760
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: cleanup pystate #1787
ffi: cleanup pystate #1787
Conversation
d61b5c4
to
308d76c
Compare
src/ffi/pystate.rs
Outdated
extern "C" { | ||
#[cfg(not(PyPy))] | ||
#[cfg_attr(docsrs, doc(not(PyPy)))] |
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.
#[cfg_attr(docsrs, doc(not(PyPy)))] | |
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))] |
Same for all the other ones.
Maybe this is worth putting on top of the extern "C"
blocks (splitting them if necessary) to reduce littering attributes everywhere?
Note that doc_cfg doesn't work with glob imports, so documenting everything in ffi with these is going to be a huge pain.
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.
Hmm. For now I'm going to keep it like this, but I agree it would be nice to find a long-term solution.
// skipped _PyErr_StackItem | ||
// skipped _PyStackChunk | ||
// skipped _ts (aka PyThreadState) | ||
|
||
extern "C" { |
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.
The cfgs in this entire block don't do anything because the entire module import is already gated with #[cfg(all(Py_3_8, not(PyPy)))]
(https://github.com/PyO3/pyo3/blob/main/src/ffi/cpython/mod.rs#L43).
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.
As above will remove that gating and make the cfgs here meaningful.
|
||
// skipped _PyInterpreterState_GetMainModule | ||
|
||
pub type Py_tracefunc = extern "C" fn( |
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.
These functions were in Include/pystate
before 3.8. The problem with moving this here now is that the cpython/pystate
module is gated behind Py_3_8
, so this removes it from 3.6 and 3.7, which is why CI is now failing. (the same thing may be true for other things)
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.
Ah. I'd rather have the ffi modules look as much like the Python headers as possible, to minimise confusion. So I'll remove that version gating and tweak things.
308d76c
to
00fe36c
Compare
00fe36c
to
0bfd50d
Compare
PyGILState_Check
andPy_tracefunc
to unlimited apiPyThreadState
an opaque struct (the current definition was totally broken, so haven't bothered mentioning this in the CHANGELOG as nobody can have been using it successfully).