From 0d78e88b14973ca3579cc47d6cdbdcf9695cc840 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sat, 4 Jun 2022 08:12:27 +0100 Subject: [PATCH] ffi: fix PyTypeObject definition on Python 3.8 --- CHANGELOG.md | 3 ++- pyo3-ffi/src/cpython/code.rs | 2 +- pyo3-ffi/src/cpython/frameobject.rs | 4 ++-- pyo3-ffi/src/cpython/object.rs | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc21fb64..1bb971ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,7 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Correct FFI definition `Py_tracefunc` to be `unsafe extern "C" fn` (was previously safe). [#2407](https://github.com/PyO3/pyo3/pull/2407) - Fix case where `ValueError` without message could be raised by the `#[derive(FromPyObject)]` generated implementation for a tuple struct. [#2414](https://github.com/PyO3/pyo3/pull/2414) - Fix compile failure when using `#[pyo3(from_py_with = "pouf")]` in on a field in a `#[derive(FromPyObject)]` struct. [#2414](https://github.com/PyO3/pyo3/pull/2414) -- Fix FFI definitions `_PyDateTime_BaseTime` lacking leading underscores in their names. [#2421](https://github.com/PyO3/pyo3/pull/2421) +- Fix FFI definitions `_PyDateTime_BaseTime` and `_PyDateTime_BaseDateTime` lacking leading underscores in their names. [#2421](https://github.com/PyO3/pyo3/pull/2421) - Remove FFI definition `PyArena` on Python 3.10 and up. [#2421](https://github.com/PyO3/pyo3/pull/2421) - Fix FFI definition `PyCompilerFlags` missing member `cf_feature_version` on Python 3.8 and up. [#2423](https://github.com/PyO3/pyo3/pull/2423) - Fix FFI definition `PyAsyncMethods` missing member `am_send` on Python 3.10 and up. [#2423](https://github.com/PyO3/pyo3/pull/2423) @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix FFI definition `PySyntaxErrorObject` missing members `end_lineno` and `end_offset` on Python 3.10 and up. [#2423](https://github.com/PyO3/pyo3/pull/2423) - Fix FFI definition `PyHeapTypeObject` missing member `ht_module` on Python 3.9 and up. [#2423](https://github.com/PyO3/pyo3/pull/2423) - Fix FFI definition `PyFrameObject` having multiple incorrect members on various Python versions. [#2424](https://github.com/PyO3/pyo3/pull/2424) +- Fix FFI definition `PyTypeObject` missing deprecated field `tp_print` on Python 3.8. [#2424](https://github.com/PyO3/pyo3/pull/2424) ## [0.16.5] - 2022-05-15 diff --git a/pyo3-ffi/src/cpython/code.rs b/pyo3-ffi/src/cpython/code.rs index 760afb71..91183c97 100644 --- a/pyo3-ffi/src/cpython/code.rs +++ b/pyo3-ffi/src/cpython/code.rs @@ -6,7 +6,7 @@ use std::os::raw::{c_char, c_int, c_uchar, c_void}; // skipped _Py_OPCODE // skipped _Py_OPARG -#[cfg(Py_3_8)] +#[cfg(all(Py_3_8, not(Py_3_11)))] opaque_struct!(_PyOpcache); #[repr(C)] diff --git a/pyo3-ffi/src/cpython/frameobject.rs b/pyo3-ffi/src/cpython/frameobject.rs index 57037b17..5074f0fd 100644 --- a/pyo3-ffi/src/cpython/frameobject.rs +++ b/pyo3-ffi/src/cpython/frameobject.rs @@ -3,12 +3,12 @@ use crate::object::*; use crate::pystate::PyThreadState; use std::os::raw::{c_char, c_int}; -// skipped _framestate - +#[cfg(not(Py_3_11))] pub type PyFrameState = c_char; #[repr(C)] #[derive(Copy, Clone)] +#[cfg(not(Py_3_11))] pub struct PyTryBlock { pub b_type: c_int, pub b_handler: c_int, diff --git a/pyo3-ffi/src/cpython/object.rs b/pyo3-ffi/src/cpython/object.rs index 86865245..97baa9af 100644 --- a/pyo3-ffi/src/cpython/object.rs +++ b/pyo3-ffi/src/cpython/object.rs @@ -276,6 +276,8 @@ pub struct PyTypeObject { pub tp_finalize: Option, #[cfg(Py_3_8)] pub tp_vectorcall: Option, + #[cfg(all(Py_3_8, not(Py_3_9)))] + pub tp_print: Option, #[cfg(PyPy)] pub tp_pypy_flags: std::os::raw::c_long, #[cfg(py_sys_config = "COUNT_ALLOCS")]