Skip to content

Commit

Permalink
Python 3.7 support for PyCodeObject. (#2726)
Browse files Browse the repository at this point in the history
* Python 3.7 support for PyCodeObject.

Co-authored-by: Itamar Turner-Trauring <[email protected]>
  • Loading branch information
itamarst and pythonspeed authored Nov 8, 2022
1 parent 7c25153 commit 6746ff8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions newsfragments/2726.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`PyCodeObject` is now once again 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

0 comments on commit 6746ff8

Please sign in to comment.