Skip to content

Commit

Permalink
ffi fixes for 3.13 beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed May 14, 2024
1 parent 6f0a2c0 commit b982fee
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ jobs:
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: "-D warnings"
# FIXME this is a temporary hack for testing 3.13 prereleases, probably we should have a flag
# PYO3_ALLOW_3_13_PRERELEASES or similar so that users don't need to run this flag in their CI
UNSAFE_PYO3_SKIP_VERSION_CHECK: "1"
4 changes: 3 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,9 @@ def update_ui_tests(session: nox.Session):

def _build_docs_for_ffi_check(session: nox.Session) -> None:
# pyo3-ffi-check needs to scrape docs of pyo3-ffi
_run_cargo(session, "doc", _FFI_CHECK, "-p", "pyo3-ffi", "--no-deps")
env = os.environ.copy()
env["PYO3_PYTHON"] = sys.executable
_run_cargo(session, "doc", _FFI_CHECK, "-p", "pyo3-ffi", "--no-deps", env=env)


@lru_cache()
Expand Down
11 changes: 10 additions & 1 deletion pyo3-ffi/src/cpython/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ pub const _PY_MONITORING_EVENTS: usize = 17;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct _Py_LocalMonitors {
pub tools: [u8; _PY_MONITORING_UNGROUPED_EVENTS],
pub tools: [u8; if cfg!(Py_3_13) {
_PY_MONITORING_LOCAL_EVENTS
} else {
_PY_MONITORING_UNGROUPED_EVENTS
}],
}

#[cfg(Py_3_12)]
Expand Down Expand Up @@ -102,6 +106,9 @@ pub struct PyCodeObject {
pub co_extra: *mut c_void,
}

#[cfg(Py_3_13)]
opaque_struct!(_PyExecutorArray);

#[cfg(all(not(any(PyPy, GraalPy)), Py_3_8, not(Py_3_11)))]
#[repr(C)]
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -176,6 +183,8 @@ pub struct PyCodeObject {
pub _co_code: *mut PyObject,
#[cfg(not(Py_3_12))]
pub _co_linearray: *mut c_char,
#[cfg(Py_3_13)]
pub co_executors: *mut _PyExecutorArray,
#[cfg(Py_3_12)]
pub _co_cached: *mut _PyCoCached,
#[cfg(Py_3_12)]
Expand Down
4 changes: 2 additions & 2 deletions pyo3-ffi/src/cpython/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct PyCompilerFlags {

// skipped non-limited _PyCompilerFlags_INIT

#[cfg(all(Py_3_12, not(any(PyPy, GraalPy))))]
#[cfg(all(Py_3_12, not(any(Py_3_13, PyPy, GraalPy))))]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _PyCompilerSrcLocation {
Expand All @@ -42,7 +42,7 @@ pub struct _PyCompilerSrcLocation {

// skipped SRC_LOCATION_FROM_AST

#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(any(PyPy, GraalPy, Py_3_13)))]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyFutureFeatures {
Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/src/cpython/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct _frozen {
pub size: c_int,
#[cfg(Py_3_11)]
pub is_package: c_int,
#[cfg(Py_3_11)]
#[cfg(all(Py_3_11, not(Py_3_13)))]
pub get_code: Option<unsafe extern "C" fn() -> *mut PyObject>,
}

Expand Down
4 changes: 4 additions & 0 deletions pyo3-ffi/src/cpython/initconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ pub struct PyConfig {
pub safe_path: c_int,
#[cfg(Py_3_12)]
pub int_max_str_digits: c_int,
#[cfg(Py_3_13)]
pub cpu_count: c_int,
pub pathconfig_warnings: c_int,
#[cfg(Py_3_10)]
pub program_name: *mut wchar_t,
Expand All @@ -165,6 +167,8 @@ pub struct PyConfig {
pub run_command: *mut wchar_t,
pub run_module: *mut wchar_t,
pub run_filename: *mut wchar_t,
#[cfg(Py_3_13)]
pub sys_path_0: *mut wchar_t,
pub _install_importlib: c_int,
pub _init_main: c_int,
#[cfg(all(Py_3_9, not(Py_3_12)))]
Expand Down
2 changes: 2 additions & 0 deletions pyo3-ffi/src/cpython/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ pub struct _specialization_cache {
pub getitem: *mut PyObject,
#[cfg(Py_3_12)]
pub getitem_version: u32,
#[cfg(Py_3_13)]
pub init: *mut PyObject,
}

#[repr(C)]
Expand Down

0 comments on commit b982fee

Please sign in to comment.