Skip to content

Commit ce2d6e9

Browse files
mattipIcxolu
authored andcommitted
Add PyPy3.11 (#4760)
* allow pypy3.11 * run CI on pypy3.11 * change const declaration * change link name for PyExc_BaseExceptionGroup * PyObject_DelAttr* are inline functions on pypy3.11 * use nightly until official release * DOC: add a news fragment * conditionally compile 'use' statements * fix format * changes from review * pypy 3.11 released * fixes for PyPy * typo * exclude _PyInterpreterFrame on PyPy * more pypy fixes * more excluding _PyFrameEvalFunction on PyPy * fixes for PyPy struct differences * format * fix test --------- Co-authored-by: Icxolu <[email protected]>
1 parent f2a8460 commit ce2d6e9

File tree

17 files changed

+35
-22
lines changed

17 files changed

+35
-22
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ jobs:
244244
"3.13",
245245
"pypy3.9",
246246
"pypy3.10",
247+
"pypy3.11",
247248
"graalpy24.0",
248249
]
249250
platform:

newsfragments/4760.packaging.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add support for PyPy3.11

noxfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
PYO3_GUIDE_TARGET = PYO3_TARGET / "guide"
3333
PYO3_DOCS_TARGET = PYO3_TARGET / "doc"
3434
PY_VERSIONS = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13")
35-
PYPY_VERSIONS = ("3.9", "3.10")
35+
PYPY_VERSIONS = ("3.9", "3.10", "3.11")
3636
FREE_THREADED_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
3737

3838

@@ -673,8 +673,8 @@ def test_version_limits(session: nox.Session):
673673
config_file.set("PyPy", "3.8")
674674
_run_cargo(session, "check", env=env, expect_error=True)
675675

676-
assert "3.11" not in PYPY_VERSIONS
677-
config_file.set("PyPy", "3.11")
676+
assert "3.12" not in PYPY_VERSIONS
677+
config_file.set("PyPy", "3.12")
678678
_run_cargo(session, "check", env=env, expect_error=True)
679679

680680

pyo3-ffi/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const SUPPORTED_VERSIONS_PYPY: SupportedVersions = SupportedVersions {
2525
min: PythonVersion { major: 3, minor: 9 },
2626
max: PythonVersion {
2727
major: 3,
28-
minor: 10,
28+
minor: 11,
2929
},
3030
};
3131

pyo3-ffi/src/abstract_.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ use crate::pyport::Py_ssize_t;
33
use std::os::raw::{c_char, c_int};
44

55
#[inline]
6-
#[cfg(all(not(Py_3_13), not(PyPy)))] // CPython exposed as a function in 3.13, in object.h
6+
#[cfg(all(
7+
not(Py_3_13), // CPython exposed as a function in 3.13, in object.h
8+
not(all(PyPy, not(Py_3_11))) // PyPy exposed as a function until PyPy 3.10, macro in 3.11+
9+
))]
710
pub unsafe fn PyObject_DelAttrString(o: *mut PyObject, attr_name: *const c_char) -> c_int {
811
PyObject_SetAttrString(o, attr_name, std::ptr::null_mut())
912
}
1013

1114
#[inline]
12-
#[cfg(all(not(Py_3_13), not(PyPy)))] // CPython exposed as a function in 3.13, in object.h
15+
#[cfg(all(
16+
not(Py_3_13), // CPython exposed as a function in 3.13, in object.h
17+
not(all(PyPy, not(Py_3_11))) // PyPy exposed as a function until PyPy 3.10, macro in 3.11+
18+
))]
1319
pub unsafe fn PyObject_DelAttr(o: *mut PyObject, attr_name: *mut PyObject) -> c_int {
1420
PyObject_SetAttr(o, attr_name, std::ptr::null_mut())
1521
}

pyo3-ffi/src/cpython/abstract_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{PyObject, Py_ssize_t};
2-
#[cfg(not(all(Py_3_11, GraalPy)))]
2+
#[cfg(any(all(Py_3_8, not(any(PyPy, GraalPy))), not(Py_3_11)))]
33
use std::os::raw::c_char;
44
use std::os::raw::c_int;
55

pyo3-ffi/src/cpython/genobject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::object::*;
22
use crate::PyFrameObject;
33
#[cfg(not(any(PyPy, GraalPy)))]
44
use crate::_PyErr_StackItem;
5-
#[cfg(all(Py_3_11, not(GraalPy)))]
5+
#[cfg(all(Py_3_11, not(any(PyPy, GraalPy))))]
66
use std::os::raw::c_char;
77
use std::os::raw::c_int;
88
use std::ptr::addr_of_mut;

pyo3-ffi/src/cpython/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub use self::object::*;
7171
pub use self::objimpl::*;
7272
pub use self::pydebug::*;
7373
pub use self::pyerrors::*;
74-
#[cfg(Py_3_11)]
74+
#[cfg(all(Py_3_11, not(PyPy)))]
7575
pub use self::pyframe::*;
7676
#[cfg(all(Py_3_8, not(PyPy)))]
7777
pub use self::pylifecycle::*;

pyo3-ffi/src/cpython/object.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ pub struct PyHeapTypeObject {
310310
pub ht_cached_keys: *mut c_void,
311311
#[cfg(Py_3_9)]
312312
pub ht_module: *mut object::PyObject,
313-
#[cfg(Py_3_11)]
313+
#[cfg(all(Py_3_11, not(PyPy)))]
314314
_ht_tpname: *mut c_char,
315-
#[cfg(Py_3_11)]
315+
#[cfg(all(Py_3_11, not(PyPy)))]
316316
_spec_cache: _specialization_cache,
317317
}
318318

pyo3-ffi/src/cpython/objimpl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(not(all(Py_3_11, GraalPy)))]
1+
#[cfg(not(all(Py_3_11, any(PyPy, GraalPy))))]
22
use libc::size_t;
33
use std::os::raw::c_int;
44

0 commit comments

Comments
 (0)