Skip to content

Commit b10d55a

Browse files
committed
support 3.13
1 parent b982fee commit b10d55a

File tree

9 files changed

+256
-90
lines changed

9 files changed

+256
-90
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,3 @@ jobs:
147147
RUST_BACKTRACE: 1
148148
RUSTFLAGS: "-D warnings"
149149
RUSTDOCFLAGS: "-D warnings"
150-
# FIXME this is a temporary hack for testing 3.13 prereleases, probably we should have a flag
151-
# PYO3_ALLOW_3_13_PRERELEASES or similar so that users don't need to run this flag in their CI
152-
UNSAFE_PYO3_SKIP_VERSION_CHECK: "1"

newsfragments/4184.packaging.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support Python 3.13.

noxfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
PYO3_GUIDE_SRC = PYO3_DIR / "guide" / "src"
3131
PYO3_GUIDE_TARGET = PYO3_TARGET / "guide"
3232
PYO3_DOCS_TARGET = PYO3_TARGET / "doc"
33-
PY_VERSIONS = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12")
33+
PY_VERSIONS = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13")
3434
PYPY_VERSIONS = ("3.7", "3.8", "3.9", "3.10")
3535

3636

@@ -631,11 +631,11 @@ def test_version_limits(session: nox.Session):
631631
config_file.set("CPython", "3.6")
632632
_run_cargo(session, "check", env=env, expect_error=True)
633633

634-
assert "3.13" not in PY_VERSIONS
635-
config_file.set("CPython", "3.13")
634+
assert "3.14" not in PY_VERSIONS
635+
config_file.set("CPython", "3.14")
636636
_run_cargo(session, "check", env=env, expect_error=True)
637637

638-
# 3.13 CPython should build with forward compatibility
638+
# 3.14 CPython should build with forward compatibility
639639
env["PYO3_USE_ABI3_FORWARD_COMPATIBILITY"] = "1"
640640
_run_cargo(session, "check", env=env)
641641

pyo3-ffi/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const SUPPORTED_VERSIONS_CPYTHON: SupportedVersions = SupportedVersions {
1717
min: PythonVersion { major: 3, minor: 7 },
1818
max: PythonVersion {
1919
major: 3,
20-
minor: 12,
20+
minor: 13,
2121
},
2222
};
2323

pyo3-ffi/src/cpython/longobject.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
use crate::longobject::*;
2+
use crate::object::*;
3+
#[cfg(Py_3_13)]
4+
use crate::pyport::Py_ssize_t;
5+
use libc::size_t;
6+
#[cfg(Py_3_13)]
7+
use std::os::raw::c_void;
8+
use std::os::raw::{c_int, c_uchar};
9+
10+
#[cfg(Py_3_13)]
11+
extern "C" {
12+
pub fn PyLong_FromUnicodeObject(u: *mut PyObject, base: c_int) -> *mut PyObject;
13+
}
14+
15+
#[cfg(Py_3_13)]
16+
pub const Py_ASNATIVEBYTES_DEFAULTS: c_int = -1;
17+
#[cfg(Py_3_13)]
18+
pub const Py_ASNATIVEBYTES_BIG_ENDIAN: c_int = 0;
19+
#[cfg(Py_3_13)]
20+
pub const Py_ASNATIVEBYTES_LITTLE_ENDIAN: c_int = 1;
21+
#[cfg(Py_3_13)]
22+
pub const Py_ASNATIVEBYTES_NATIVE_ENDIAN: c_int = 3;
23+
#[cfg(Py_3_13)]
24+
pub const Py_ASNATIVEBYTES_UNSIGNED_BUFFER: c_int = 4;
25+
#[cfg(Py_3_13)]
26+
pub const Py_ASNATIVEBYTES_REJECT_NEGATIVE: c_int = 8;
27+
28+
extern "C" {
29+
// skipped _PyLong_Sign
30+
31+
#[cfg(Py_3_13)]
32+
pub fn PyLong_AsNativeBytes(
33+
v: *mut PyObject,
34+
buffer: *mut c_void,
35+
n_bytes: Py_ssize_t,
36+
flags: c_int,
37+
) -> Py_ssize_t;
38+
39+
#[cfg(Py_3_13)]
40+
pub fn PyLong_FromNativeBytes(
41+
buffer: *const c_void,
42+
n_bytes: size_t,
43+
flags: c_int,
44+
) -> *mut PyObject;
45+
46+
#[cfg(Py_3_13)]
47+
pub fn PyLong_FromUnsignedNativeBytes(
48+
buffer: *const c_void,
49+
n_bytes: size_t,
50+
flags: c_int,
51+
) -> *mut PyObject;
52+
53+
// skipped PyUnstable_Long_IsCompact
54+
// skipped PyUnstable_Long_CompactValue
55+
56+
#[cfg_attr(PyPy, link_name = "_PyPyLong_FromByteArray")]
57+
pub fn _PyLong_FromByteArray(
58+
bytes: *const c_uchar,
59+
n: size_t,
60+
little_endian: c_int,
61+
is_signed: c_int,
62+
) -> *mut PyObject;
63+
64+
#[cfg_attr(PyPy, link_name = "_PyPyLong_AsByteArrayO")]
65+
pub fn _PyLong_AsByteArray(
66+
v: *mut PyLongObject,
67+
bytes: *mut c_uchar,
68+
n: size_t,
69+
little_endian: c_int,
70+
is_signed: c_int,
71+
) -> c_int;
72+
73+
// skipped _PyLong_GCD
74+
}

pyo3-ffi/src/cpython/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub(crate) mod import;
1818
pub(crate) mod initconfig;
1919
// skipped interpreteridobject.h
2020
pub(crate) mod listobject;
21+
pub(crate) mod longobject;
2122
#[cfg(all(Py_3_9, not(PyPy)))]
2223
pub(crate) mod methodobject;
2324
pub(crate) mod object;
@@ -53,6 +54,7 @@ pub use self::import::*;
5354
#[cfg(all(Py_3_8, not(PyPy)))]
5455
pub use self::initconfig::*;
5556
pub use self::listobject::*;
57+
pub use self::longobject::*;
5658
#[cfg(all(Py_3_9, not(PyPy)))]
5759
pub use self::methodobject::*;
5860
pub use self::object::*;

pyo3-ffi/src/longobject.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use crate::object::*;
22
use crate::pyport::Py_ssize_t;
33
use libc::size_t;
4-
#[cfg(not(Py_LIMITED_API))]
5-
use std::os::raw::c_uchar;
64
use std::os::raw::{c_char, c_double, c_int, c_long, c_longlong, c_ulong, c_ulonglong, c_void};
75
use std::ptr::addr_of_mut;
86

@@ -90,34 +88,12 @@ extern "C" {
9088
arg3: c_int,
9189
) -> *mut PyObject;
9290
}
93-
// skipped non-limited PyLong_FromUnicodeObject
94-
// skipped non-limited _PyLong_FromBytes
9591

9692
#[cfg(not(Py_LIMITED_API))]
9793
extern "C" {
98-
// skipped non-limited _PyLong_Sign
99-
10094
#[cfg_attr(PyPy, link_name = "_PyPyLong_NumBits")]
95+
#[cfg(not(Py_3_13))]
10196
pub fn _PyLong_NumBits(obj: *mut PyObject) -> size_t;
102-
103-
// skipped _PyLong_DivmodNear
104-
105-
#[cfg_attr(PyPy, link_name = "_PyPyLong_FromByteArray")]
106-
pub fn _PyLong_FromByteArray(
107-
bytes: *const c_uchar,
108-
n: size_t,
109-
little_endian: c_int,
110-
is_signed: c_int,
111-
) -> *mut PyObject;
112-
113-
#[cfg_attr(PyPy, link_name = "_PyPyLong_AsByteArrayO")]
114-
pub fn _PyLong_AsByteArray(
115-
v: *mut PyLongObject,
116-
bytes: *mut c_uchar,
117-
n: size_t,
118-
little_endian: c_int,
119-
is_signed: c_int,
120-
) -> c_int;
12197
}
12298

12399
// skipped non-limited _PyLong_Format
@@ -130,6 +106,5 @@ extern "C" {
130106
pub fn PyOS_strtol(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_long;
131107
}
132108

133-
// skipped non-limited _PyLong_GCD
134109
// skipped non-limited _PyLong_Rshift
135110
// skipped non-limited _PyLong_Lshift

0 commit comments

Comments
 (0)