Skip to content
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

Bump supported cpython version to 3.14 for testing #4811

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ jobs:
"3.11",
"3.12",
"3.13",
"3.14-dev",
"pypy3.9",
"pypy3.10",
"graalpy24.0",
Expand Down Expand Up @@ -520,8 +521,8 @@ jobs:
components: rust-src
- name: Install python3 standalone debug build with nox
run: |
PBS_RELEASE="20241016"
PBS_PYTHON_VERSION="3.13.0"
PBS_RELEASE="20241219"
PBS_PYTHON_VERSION="3.13.1"
PBS_ARCHIVE="cpython-${PBS_PYTHON_VERSION}+${PBS_RELEASE}-x86_64-unknown-linux-gnu-debug-full.tar.zst"
wget "https://github.com/indygreg/python-build-standalone/releases/download/${PBS_RELEASE}/${PBS_ARCHIVE}"
tar -I zstd -xf "${PBS_ARCHIVE}"
Expand Down
1 change: 1 addition & 0 deletions newsfragments/4802.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed missing struct fields on GraalPy when subclassing builtin classes
1 change: 1 addition & 0 deletions newsfragments/4811.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump supported cpython version to 3.14 for testing
1 change: 1 addition & 0 deletions newsfragments/4814.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`derive(FromPyObject)` support raw identifiers like `r#box`.
1 change: 1 addition & 0 deletions newsfragments/4822.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bumped `target-lexicon` dependency to 0.13
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
PYO3_GUIDE_SRC = PYO3_DIR / "guide" / "src"
PYO3_GUIDE_TARGET = PYO3_TARGET / "guide"
PYO3_DOCS_TARGET = PYO3_TARGET / "doc"
PY_VERSIONS = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13")
PY_VERSIONS = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14")
PYPY_VERSIONS = ("3.9", "3.10")
FREE_THREADED_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))

Expand Down Expand Up @@ -660,8 +660,8 @@ def test_version_limits(session: nox.Session):
config_file.set("CPython", "3.6")
_run_cargo(session, "check", env=env, expect_error=True)

assert "3.14" not in PY_VERSIONS
config_file.set("CPython", "3.14")
assert "3.15" not in PY_VERSIONS
config_file.set("CPython", "3.15")
_run_cargo(session, "check", env=env, expect_error=True)

# 3.14 CPython should build with forward compatibility
Expand Down
4 changes: 2 additions & 2 deletions pyo3-build-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ rust-version = "1.63"
[dependencies]
once_cell = "1"
python3-dll-a = { version = "0.2.11", optional = true }
target-lexicon = "0.12.14"
target-lexicon = "0.13"

[build-dependencies]
python3-dll-a = { version = "0.2.11", optional = true }
target-lexicon = "0.12.14"
target-lexicon = "0.13"

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,8 @@ impl CrossCompileConfig {
&& host.operating_system == OperatingSystem::Windows;

// Not cross-compiling to compile for x86-64 Python from macOS arm64 and vice versa
compatible |= target.operating_system == OperatingSystem::Darwin
&& host.operating_system == OperatingSystem::Darwin;
compatible |= matches!(target.operating_system, OperatingSystem::Darwin(_))
&& matches!(host.operating_system, OperatingSystem::Darwin(_));

!compatible
}
Expand Down
7 changes: 6 additions & 1 deletion pyo3-build-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn add_extension_module_link_args() {
}

fn _add_extension_module_link_args(triple: &Triple, mut writer: impl std::io::Write) {
if triple.operating_system == OperatingSystem::Darwin {
if matches!(triple.operating_system, OperatingSystem::Darwin(_)) {
writeln!(writer, "cargo:rustc-cdylib-link-arg=-undefined").unwrap();
writeln!(writer, "cargo:rustc-cdylib-link-arg=dynamic_lookup").unwrap();
} else if triple == &Triple::from_str("wasm32-unknown-emscripten").unwrap() {
Expand Down Expand Up @@ -160,6 +160,10 @@ pub fn print_feature_cfgs() {
if rustc_minor_version >= 83 {
println!("cargo:rustc-cfg=io_error_more");
}

if rustc_minor_version >= 85 {
println!("cargo:rustc-cfg=fn_ptr_eq");
}
}

/// Registers `pyo3`s config names as reachable cfg expressions
Expand All @@ -185,6 +189,7 @@ pub fn print_expected_cfgs() {
println!("cargo:rustc-check-cfg=cfg(c_str_lit)");
println!("cargo:rustc-check-cfg=cfg(rustc_has_once_lock)");
println!("cargo:rustc-check-cfg=cfg(io_error_more)");
println!("cargo:rustc-check-cfg=cfg(fn_ptr_eq)");

// allow `Py_3_*` cfgs from the minimum supported version up to the
// maximum minor version (+1 for development for the next)
Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SUPPORTED_VERSIONS_CPYTHON: SupportedVersions = SupportedVersions {
min: PythonVersion { major: 3, minor: 7 },
max: PythonVersion {
major: 3,
minor: 13,
minor: 14,
},
};

Expand Down
1 change: 0 additions & 1 deletion pyo3-ffi/src/abstract_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub unsafe fn PyObject_DelAttr(o: *mut PyObject, attr_name: *mut PyObject) -> c_
extern "C" {
#[cfg(all(
not(PyPy),
not(GraalPy),
any(Py_3_10, all(not(Py_LIMITED_API), Py_3_9)) // Added to python in 3.9 but to limited API in 3.10
))]
#[cfg_attr(PyPy, link_name = "PyPyObject_CallNoArgs")]
Expand Down
4 changes: 3 additions & 1 deletion pyo3-ffi/src/cpython/abstract_.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::{PyObject, Py_ssize_t};
use std::os::raw::{c_char, c_int};
#[cfg(not(all(Py_3_11, GraalPy)))]
use std::os::raw::c_char;
use std::os::raw::c_int;

#[cfg(not(Py_3_11))]
use crate::Py_buffer;
Expand Down
1 change: 0 additions & 1 deletion pyo3-ffi/src/cpython/complexobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub struct Py_complex {
#[repr(C)]
pub struct PyComplexObject {
pub ob_base: PyObject,
#[cfg(not(GraalPy))]
pub cval: Py_complex,
}

Expand Down
1 change: 0 additions & 1 deletion pyo3-ffi/src/cpython/floatobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::os::raw::c_double;
#[repr(C)]
pub struct PyFloatObject {
pub ob_base: PyObject,
#[cfg(not(GraalPy))]
pub ob_fval: c_double,
}

Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/src/cpython/genobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::object::*;
use crate::PyFrameObject;
#[cfg(not(any(PyPy, GraalPy)))]
use crate::_PyErr_StackItem;
#[cfg(Py_3_11)]
#[cfg(all(Py_3_11, not(GraalPy)))]
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
Expand Down
4 changes: 2 additions & 2 deletions pyo3-ffi/src/cpython/listobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use crate::object::*;
#[cfg(not(PyPy))]
use crate::pyport::Py_ssize_t;

#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
#[repr(C)]
pub struct PyListObject {
pub ob_base: PyVarObject,
pub ob_item: *mut *mut PyObject,
pub allocated: Py_ssize_t,
}

#[cfg(any(PyPy, GraalPy))]
#[cfg(PyPy)]
pub struct PyListObject {
pub ob_base: PyObject,
}
Expand Down
2 changes: 0 additions & 2 deletions pyo3-ffi/src/cpython/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ pub type printfunc =
#[derive(Debug)]
pub struct PyTypeObject {
pub ob_base: object::PyVarObject,
#[cfg(GraalPy)]
pub ob_size: Py_ssize_t,
pub tp_name: *const c_char,
pub tp_basicsize: Py_ssize_t,
pub tp_itemsize: Py_ssize_t,
Expand Down
1 change: 1 addition & 0 deletions pyo3-ffi/src/cpython/objimpl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(all(Py_3_11, GraalPy)))]
use libc::size_t;
use std::os::raw::c_int;

Expand Down
28 changes: 14 additions & 14 deletions pyo3-ffi/src/cpython/pyerrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ use crate::Py_ssize_t;
#[derive(Debug)]
pub struct PyBaseExceptionObject {
pub ob_base: PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub dict: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub args: *mut PyObject,
#[cfg(all(Py_3_11, not(any(PyPy, GraalPy))))]
#[cfg(all(Py_3_11, not(PyPy)))]
pub notes: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub traceback: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub context: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub cause: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub suppress_context: char,
}

Expand Down Expand Up @@ -134,19 +134,19 @@ pub struct PyOSErrorObject {
#[derive(Debug)]
pub struct PyStopIterationObject {
pub ob_base: PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub dict: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub args: *mut PyObject,
#[cfg(all(Py_3_11, not(any(PyPy, GraalPy))))]
#[cfg(all(Py_3_11, not(PyPy)))]
pub notes: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub traceback: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub context: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub cause: *mut PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub suppress_context: char,

pub value: *mut PyObject,
Expand Down
1 change: 0 additions & 1 deletion pyo3-ffi/src/cpython/tupleobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::pyport::Py_ssize_t;
#[repr(C)]
pub struct PyTupleObject {
pub ob_base: PyVarObject,
#[cfg(not(GraalPy))]
pub ob_item: [*mut PyObject; 1],
}

Expand Down
13 changes: 4 additions & 9 deletions pyo3-ffi/src/cpython/unicodeobject.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
use crate::Py_hash_t;
use crate::{PyObject, Py_UCS1, Py_UCS2, Py_UCS4, Py_ssize_t};
use libc::wchar_t;
Expand Down Expand Up @@ -250,9 +250,8 @@ impl From<PyASCIIObjectState> for u32 {
#[repr(C)]
pub struct PyASCIIObject {
pub ob_base: PyObject,
#[cfg(not(GraalPy))]
pub length: Py_ssize_t,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub hash: Py_hash_t,
/// A bit field with various properties.
///
Expand All @@ -265,9 +264,8 @@ pub struct PyASCIIObject {
/// unsigned int ascii:1;
/// unsigned int ready:1;
/// unsigned int :24;
#[cfg(not(GraalPy))]
pub state: u32,
#[cfg(not(any(Py_3_12, GraalPy)))]
#[cfg(not(Py_3_12))]
pub wstr: *mut wchar_t,
}

Expand Down Expand Up @@ -379,11 +377,9 @@ impl PyASCIIObject {
#[repr(C)]
pub struct PyCompactUnicodeObject {
pub _base: PyASCIIObject,
#[cfg(not(GraalPy))]
pub utf8_length: Py_ssize_t,
#[cfg(not(GraalPy))]
pub utf8: *mut c_char,
#[cfg(not(any(Py_3_12, GraalPy)))]
#[cfg(not(Py_3_12))]
pub wstr_length: Py_ssize_t,
}

Expand All @@ -398,7 +394,6 @@ pub union PyUnicodeObjectData {
#[repr(C)]
pub struct PyUnicodeObject {
pub _base: PyCompactUnicodeObject,
#[cfg(not(GraalPy))]
pub data: PyUnicodeObjectData,
}

Expand Down
30 changes: 11 additions & 19 deletions pyo3-ffi/src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ use crate::PyCapsule_Import;
#[cfg(GraalPy)]
use crate::{PyLong_AsLong, PyLong_Check, PyObject_GetAttrString, Py_DecRef};
use crate::{PyObject, PyObject_TypeCheck, PyTypeObject, Py_TYPE};
#[cfg(not(GraalPy))]
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::ptr;
use std::sync::Once;
use std::{cell::UnsafeCell, ffi::CStr};
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
use {crate::Py_hash_t, std::os::raw::c_uchar};
// Type struct wrappers
const _PyDateTime_DATE_DATASIZE: usize = 4;
Expand All @@ -27,13 +26,10 @@ const _PyDateTime_DATETIME_DATASIZE: usize = 10;
/// Structure representing a `datetime.timedelta`.
pub struct PyDateTime_Delta {
pub ob_base: PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub hashcode: Py_hash_t,
#[cfg(not(GraalPy))]
pub days: c_int,
#[cfg(not(GraalPy))]
pub seconds: c_int,
#[cfg(not(GraalPy))]
pub microseconds: c_int,
}

Expand All @@ -56,19 +52,17 @@ pub struct _PyDateTime_BaseTime {
/// Structure representing a `datetime.time`.
pub struct PyDateTime_Time {
pub ob_base: PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub hashcode: Py_hash_t,
#[cfg(not(GraalPy))]
pub hastzinfo: c_char,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub data: [c_uchar; _PyDateTime_TIME_DATASIZE],
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub fold: c_uchar,
/// # Safety
///
/// Care should be taken when reading this field. If the time does not have a
/// tzinfo then CPython may allocate as a `_PyDateTime_BaseTime` without this field.
#[cfg(not(GraalPy))]
pub tzinfo: *mut PyObject,
}

Expand All @@ -77,11 +71,11 @@ pub struct PyDateTime_Time {
/// Structure representing a `datetime.date`
pub struct PyDateTime_Date {
pub ob_base: PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub hashcode: Py_hash_t,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub hastzinfo: c_char,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub data: [c_uchar; _PyDateTime_DATE_DATASIZE],
}

Expand All @@ -101,19 +95,17 @@ pub struct _PyDateTime_BaseDateTime {
/// Structure representing a `datetime.datetime`.
pub struct PyDateTime_DateTime {
pub ob_base: PyObject,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub hashcode: Py_hash_t,
#[cfg(not(GraalPy))]
pub hastzinfo: c_char,
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub data: [c_uchar; _PyDateTime_DATETIME_DATASIZE],
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(PyPy))]
pub fold: c_uchar,
/// # Safety
///
/// Care should be taken when reading this field. If the time does not have a
/// tzinfo then CPython may allocate as a `_PyDateTime_BaseDateTime` without this field.
#[cfg(not(GraalPy))]
pub tzinfo: *mut PyObject,
}

Expand Down
3 changes: 3 additions & 0 deletions pyo3-ffi/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ pub struct PyVarObject {
pub ob_base: PyObject,
#[cfg(not(GraalPy))]
pub ob_size: Py_ssize_t,
// On GraalPy the field is physically there, but not always populated. We hide it to prevent accidental misuse
#[cfg(GraalPy)]
pub _ob_size_graalpy: Py_ssize_t,
}

// skipped private _PyVarObject_CAST
Expand Down
Loading
Loading