Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Python 3.7 support for PyCodeObject. #2726

Merged
merged 3 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/2727.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`PyCodeObject` is now defined with fields on Python 3.7.
28 changes: 27 additions & 1 deletion pyo3-ffi/src/cpython/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,35 @@ use std::os::raw::{c_char, c_int, c_uchar, c_void};
#[cfg(all(Py_3_8, not(PyPy), not(Py_3_11)))]
opaque_struct!(_PyOpcache);

#[cfg(all(not(PyPy), not(Py_3_8)))]
#[cfg(all(not(PyPy), not(Py_3_7)))]
opaque_struct!(PyCodeObject);

#[cfg(all(not(PyPy), Py_3_7, not(Py_3_8)))]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyCodeObject {
pub ob_base: PyObject,
pub co_argcount: c_int,
pub co_kwonlyargcount: c_int,
pub co_nlocals: c_int,
pub co_stacksize: c_int,
pub co_flags: c_int,
pub co_firstlineno: c_int,
pub co_code: *mut PyObject,
pub co_consts: *mut PyObject,
pub co_names: *mut PyObject,
pub co_varnames: *mut PyObject,
pub co_freevars: *mut PyObject,
pub co_cellvars: *mut PyObject,
pub co_cell2arg: *mut Py_ssize_t,
pub co_filename: *mut PyObject,
pub co_name: *mut PyObject,
pub co_lnotab: *mut PyObject,
pub co_zombieframe: *mut c_void,
pub co_weakreflist: *mut PyObject,
pub co_extra: *mut c_void,
}

#[cfg(all(not(PyPy), Py_3_8, not(Py_3_11)))]
#[repr(C)]
#[derive(Copy, Clone)]
Expand Down