From 02f3d5cc9020268e8fab3edc811f160bc6d4a9cc Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 8 Jan 2021 16:08:44 +0100 Subject: [PATCH] Deprecate functions from PEP 623 --- CHANGELOG.md | 1 + src/ffi/unicodeobject.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cff2d964..ecd11102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Deprecate FFI definition `PyOS_AfterFork` for Python 3.7 and up. [#1348](https://github.com/PyO3/pyo3/pull/1348) - Deprecate FFI definition `PyCoro_Check` and `PyAsyncGen_Check` in favor of `PyCoro_CheckExact` and `PyAsyncGen_CheckExact` respectively to mirror Python API. [#1348](https://github.com/PyO3/pyo3/pull/1348) - Deprecate FFI definition `PyCoroWrapper_Check` which has never been in the Python API. [#1348](https://github.com/PyO3/pyo3/pull/1348) +- Deprecate FFI definitions for `PyUnicode_FromUnicode`, `PyUnicode_AsUnicode` and `PyUnicode_AsUnicodeAndSize`, which will be removed from 3.12 and up due to [PEP 613](https://www.python.org/dev/peps/pep-0623/). [#1370](https://github.com/PyO3/pyo3/pull/1370) ### Removed - Remove FFI definition `PyFrame_ClearFreeList` when building for Python 3.9. [#1341](https://github.com/PyO3/pyo3/pull/1341) diff --git a/src/ffi/unicodeobject.rs b/src/ffi/unicodeobject.rs index 0ecfbac9..165e7aff 100644 --- a/src/ffi/unicodeobject.rs +++ b/src/ffi/unicodeobject.rs @@ -58,7 +58,8 @@ extern "C" { length: Py_ssize_t, fill_char: Py_UCS4, ) -> Py_ssize_t; - #[cfg(not(Py_LIMITED_API))] + #[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))] + #[deprecated] #[cfg_attr(PyPy, link_name = "PyPyUnicode_FromUnicode")] pub fn PyUnicode_FromUnicode(u: *const Py_UNICODE, size: Py_ssize_t) -> *mut PyObject; @@ -85,10 +86,12 @@ extern "C" { copy_null: c_int, ) -> *mut Py_UCS4; pub fn PyUnicode_AsUCS4Copy(unicode: *mut PyObject) -> *mut Py_UCS4; - #[cfg(not(Py_LIMITED_API))] + #[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))] + #[deprecated] #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUnicode")] pub fn PyUnicode_AsUnicode(unicode: *mut PyObject) -> *mut Py_UNICODE; - #[cfg(not(Py_LIMITED_API))] + #[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))] + #[deprecated] #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUnicodeAndSize")] pub fn PyUnicode_AsUnicodeAndSize( unicode: *mut PyObject,