Skip to content

Commit b2acd66

Browse files
committed
Resolve symbol errors with Python 3.12
Symbols missing in /opt/hostedtoolcache/Python/3.12.4/x64/lib/libpython3.12.so: PyCode_New PyCode_NewWithPosOnlyArgs PyUnicode_AsUnicode PyUnicode_AsUnicodeAndSize PyUnicode_FromUnicode _Py_GetAllocatedBlocks _Py_PackageContext Python 3.12/3.11 renamed/deprecated some APIs. Update code to skip them. This affects `linux (ubuntu-latest, 3.12, nightly)` CI.
1 parent 4fe0dc7 commit b2acd66

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

Diff for: python3-sys/src/code.rs

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ pub const CO_MAXBLOCKS: usize = 20;
152152
extern "C" {
153153
pub static mut PyCode_Type: PyTypeObject;
154154

155+
#[cfg_attr(Py_3_12, link_name = "PyUnstable_Code_New")]
155156
pub fn PyCode_New(
156157
argcount: c_int,
157158
kwonlyargcount: c_int,
@@ -175,6 +176,7 @@ extern "C" {
175176
) -> *mut PyCodeObject;
176177

177178
#[cfg(Py_3_8)]
179+
#[cfg_attr(Py_3_12, link_name = "PyUnstable_Code_NewWithPosOnlyArgs")]
178180
pub fn PyCode_NewWithPosOnlyArgs(
179181
argcount: c_int,
180182
posonlyargcount: c_int,

Diff for: python3-sys/src/modsupport.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub unsafe fn PyModule_FromDefAndSpec(def: *mut PyModuleDef, spec: *mut PyObject
133133
)
134134
}
135135

136-
#[cfg(not(Py_LIMITED_API))]
136+
#[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))]
137137
#[cfg_attr(windows, link(name = "pythonXY"))]
138138
extern "C" {
139139
pub static mut _Py_PackageContext: *const c_char;

Diff for: python3-sys/src/objimpl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern "C" {
2121
#[cfg(all(py_sys_config = "Py_DEBUG", not(Py_3_4)))]
2222
pub fn _PyObject_DebugFree(arg1: *mut c_void);
2323

24-
#[cfg(all(not(Py_LIMITED_API), Py_3_4))]
24+
#[cfg(all(not(Py_LIMITED_API), Py_3_4, not(Py_3_11)))]
2525
pub fn _Py_GetAllocatedBlocks() -> Py_ssize_t;
2626
pub fn PyObject_Init(arg1: *mut PyObject, arg2: *mut PyTypeObject) -> *mut PyObject;
2727
pub fn PyObject_InitVar(

Diff for: python3-sys/src/unicodeobject.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern "C" {
5252
length: Py_ssize_t,
5353
fill_char: Py_UCS4,
5454
) -> Py_ssize_t;
55-
#[cfg(not(Py_LIMITED_API))]
55+
#[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))]
5656
#[deprecated(since = "0.2.1", note = "Deprecated since Python 3.3 / PEP 393")]
5757
pub fn PyUnicode_FromUnicode(u: *const Py_UNICODE, size: Py_ssize_t) -> *mut PyObject;
5858

@@ -78,10 +78,10 @@ extern "C" {
7878
copy_null: c_int,
7979
) -> *mut Py_UCS4;
8080
pub fn PyUnicode_AsUCS4Copy(unicode: *mut PyObject) -> *mut Py_UCS4;
81-
#[cfg(not(Py_LIMITED_API))]
81+
#[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))]
8282
#[deprecated(since = "0.2.1", note = "Deprecated since Python 3.3 / PEP 393")]
8383
pub fn PyUnicode_AsUnicode(unicode: *mut PyObject) -> *mut Py_UNICODE;
84-
#[cfg(not(Py_LIMITED_API))]
84+
#[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))]
8585
#[deprecated(since = "0.2.1", note = "Deprecated since Python 3.3 / PEP 393")]
8686
pub fn PyUnicode_AsUnicodeAndSize(
8787
unicode: *mut PyObject,

0 commit comments

Comments
 (0)