Skip to content

Commit db41e02

Browse files
committed
Remove various deprecated statics
these have all been deprecated in CPython since 3.12, will be removed in 3.14, and we've deprecaed them for more than 2 years. also in the latest rust nightly, `#[deprecated]` doesn't work on statics and emits warnings
1 parent b788b9b commit db41e02

File tree

3 files changed

+7
-62
lines changed

3 files changed

+7
-62
lines changed

newsfragments/5333.removed.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
removed `Py_DebugFlag`, `Py_VerboseFlag`, `Py_QuietFlag`, `Py_InteractiveFlag`, `Py_InspectFlag`, `Py_OptimizeFlag`, `Py_NoSiteFlag`, `Py_BytesWarningFlag`, `Py_UseClassExceptionsFlag`, `Py_FrozenFlag`, `Py_IgnoreEnvironmentFlag`, `Py_DontWriteBytecodeFlag`, `Py_NoUserSiteDirectory`, `Py_UnbufferedStdioFlag`, `Py_HashRandomizationFlag`, `Py_IsolatedFlag`, `Py_LegacyWindowsFSEncodingFlag`, `Py_LegacyWindowsStdioFlag`, `Py_FileSystemDefaultEncoding`, `Py_FileSystemDefaultEncodeErrors`, `Py_HasFileSystemDefaultEncoding`
2+
3+
these have all been deprecated in CPython since 3.12, will be removed in 3.14, and we've deprecaed them for more than 2 years.

pyo3-ffi/src/cpython/pydebug.rs

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,12 @@
1-
use std::ffi::{c_char, c_int};
1+
use std::ffi::c_char;
2+
#[cfg(all(not(Py_LIMITED_API), not(Py_3_11)))]
3+
use std::ffi::c_int;
24

3-
#[cfg(not(Py_LIMITED_API))]
5+
#[cfg(all(not(Py_LIMITED_API), not(Py_3_11)))]
46
#[cfg_attr(windows, link(name = "pythonXY"))]
57
extern "C" {
6-
#[deprecated(note = "Python 3.12")]
7-
#[cfg_attr(PyPy, link_name = "PyPy_DebugFlag")]
8-
pub static mut Py_DebugFlag: c_int;
9-
#[deprecated(note = "Python 3.12")]
10-
#[cfg_attr(PyPy, link_name = "PyPy_VerboseFlag")]
11-
pub static mut Py_VerboseFlag: c_int;
12-
#[deprecated(note = "Python 3.12")]
13-
pub static mut Py_QuietFlag: c_int;
14-
#[deprecated(note = "Python 3.12")]
15-
#[cfg_attr(PyPy, link_name = "PyPy_InteractiveFlag")]
16-
pub static mut Py_InteractiveFlag: c_int;
17-
#[deprecated(note = "Python 3.12")]
18-
#[cfg_attr(PyPy, link_name = "PyPy_InspectFlag")]
19-
pub static mut Py_InspectFlag: c_int;
20-
#[deprecated(note = "Python 3.12")]
21-
#[cfg_attr(PyPy, link_name = "PyPy_OptimizeFlag")]
22-
pub static mut Py_OptimizeFlag: c_int;
23-
#[deprecated(note = "Python 3.12")]
24-
#[cfg_attr(PyPy, link_name = "PyPy_NoSiteFlag")]
25-
pub static mut Py_NoSiteFlag: c_int;
26-
#[deprecated(note = "Python 3.12")]
27-
#[cfg_attr(PyPy, link_name = "PyPy_BytesWarningFlag")]
28-
pub static mut Py_BytesWarningFlag: c_int;
29-
#[deprecated(note = "Python 3.12")]
30-
#[cfg_attr(PyPy, link_name = "PyPy_UseClassExceptionsFlag")]
31-
pub static mut Py_UseClassExceptionsFlag: c_int;
32-
#[deprecated(note = "Python 3.12")]
33-
#[cfg_attr(PyPy, link_name = "PyPy_FrozenFlag")]
34-
pub static mut Py_FrozenFlag: c_int;
35-
#[deprecated(note = "Python 3.12")]
368
#[cfg_attr(PyPy, link_name = "PyPy_IgnoreEnvironmentFlag")]
379
pub static mut Py_IgnoreEnvironmentFlag: c_int;
38-
#[deprecated(note = "Python 3.12")]
39-
#[cfg_attr(PyPy, link_name = "PyPy_DontWriteBytecodeFlag")]
40-
pub static mut Py_DontWriteBytecodeFlag: c_int;
41-
#[deprecated(note = "Python 3.12")]
42-
#[cfg_attr(PyPy, link_name = "PyPy_NoUserSiteDirectory")]
43-
pub static mut Py_NoUserSiteDirectory: c_int;
44-
#[deprecated(note = "Python 3.12")]
45-
pub static mut Py_UnbufferedStdioFlag: c_int;
46-
#[cfg_attr(PyPy, link_name = "PyPy_HashRandomizationFlag")]
47-
pub static mut Py_HashRandomizationFlag: c_int;
48-
#[deprecated(note = "Python 3.12")]
49-
pub static mut Py_IsolatedFlag: c_int;
50-
#[cfg(windows)]
51-
#[deprecated(note = "Python 3.12")]
52-
pub static mut Py_LegacyWindowsFSEncodingFlag: c_int;
53-
#[cfg(windows)]
54-
#[deprecated(note = "Python 3.12")]
55-
pub static mut Py_LegacyWindowsStdioFlag: c_int;
5610
}
5711

5812
extern "C" {
@@ -63,7 +17,6 @@ extern "C" {
6317
#[cfg(not(Py_3_11))]
6418
#[inline(always)]
6519
pub unsafe fn Py_GETENV(name: *const c_char) -> *mut c_char {
66-
#[allow(deprecated)]
6720
if Py_IgnoreEnvironmentFlag != 0 {
6821
std::ptr::null_mut()
6922
} else {

pyo3-ffi/src/fileobject.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,4 @@ extern "C" {
2424
pub fn PyObject_AsFileDescriptor(arg1: *mut PyObject) -> c_int;
2525
}
2626

27-
#[cfg_attr(windows, link(name = "pythonXY"))]
28-
extern "C" {
29-
#[deprecated(note = "Python 3.12")]
30-
pub static mut Py_FileSystemDefaultEncoding: *const c_char;
31-
#[deprecated(note = "Python 3.12")]
32-
pub static mut Py_FileSystemDefaultEncodeErrors: *const c_char;
33-
#[deprecated(note = "Python 3.12")]
34-
pub static mut Py_HasFileSystemDefaultEncoding: c_int;
35-
// skipped 3.12-deprecated Py_UTF8Mode
36-
}
37-
3827
// skipped _PyIsSelectable_fd

0 commit comments

Comments
 (0)