GeezerVison is showing github.com — Schedule removal of PyUnicode_AsDecoded/Encoded functions · Issue #132798 · python/cpython
Schedule removal of PyUnicode_AsDecoded/Encoded functions #132798Labels interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error Description
- PyUnicode_AsDecodedObject
- PyUnicode_AsDecodedUnicode
- PyUnicode_AsEncodedUnicode
- PyUnicode_AsEncodedObject
Were deprecated in 3.6 in 0093907 by @serhiy-storchaka
They have no documentation.
Will schedule them for removal in 3.15 as suggested by @vstinner in #46236 (comment)
Linked PRs
Activityhugovk commented on Apr 22, 2025
Will schedule them for removal in 3.15 as suggested by @vstinner in #46236 (comment)
Before we schedule it, remember to do a code search first:
IMO now it's too late for the 3.14 release cycle. It would be better to schedule such removal at the start of a new dev cycle, such as Python 3.15. Someone also has to check if these functions are used in the wild (ex: run a code search).
Please can you do this?
For example, GitHub code search, https://grep.app, or https://hugovk.dev/blog/2022/how-to-search-5000-python-projects/. StanFromIreland commented on Apr 22, 2025 I did a (github) code search and found no recent uses. (Some (~4 for each) old repositories that have not been updated in the last ~8 years.) vstinner commented on Apr 22, 2025 A code search on PyPI top 8,000 PyPI projects found matches in 2 projects:
- nanobind (2.4.0)
- orjson (3.10.15)
I used the regex: PyUnicode_AsDecodedObject|PyUnicode_AsDecodedUnicode|PyUnicode_AsEncodedUnicode|PyUnicode_AsEncodedObject.
nanobind-2.4.0.tar.gz: nanobind-2.4.0/cmake/darwin-ld-cpython.sym: -U _PyUnicode_AsDecodedObject
nanobind-2.4.0.tar.gz: nanobind-2.4.0/cmake/darwin-ld-cpython.sym: -U _PyUnicode_AsDecodedUnicode
nanobind-2.4.0.tar.gz: nanobind-2.4.0/cmake/darwin-ld-cpython.sym: -U _PyUnicode_AsEncodedObject
nanobind-2.4.0.tar.gz: nanobind-2.4.0/cmake/darwin-ld-cpython.sym: -U _PyUnicode_AsEncodedUnicode
nanobind-2.4.0.tar.gz: nanobind-2.4.0/cmake/darwin-ld-pypy.sym: -U _PyPyUnicode_AsEncodedObject
orjson-3.10.15.tar.gz: orjson-3.10.15/include/pyo3/pyo3-ffi/src/unicodeobject.rs: pub fn PyUnicode_AsDecodedObject(
orjson-3.10.15.tar.gz: orjson-3.10.15/include/pyo3/pyo3-ffi/src/unicodeobject.rs: pub fn PyUnicode_AsDecodedUnicode(
orjson-3.10.15.tar.gz: orjson-3.10.15/include/pyo3/pyo3-ffi/src/unicodeobject.rs: #[cfg_attr(PyPy, link_name = "PyPyUnicode_AsEncodedObject")]
orjson-3.10.15.tar.gz: orjson-3.10.15/include/pyo3/pyo3-ffi/src/unicodeobject.rs: pub fn PyUnicode_AsEncodedObject(
orjson-3.10.15.tar.gz: orjson-3.10.15/include/pyo3/pyo3-ffi/src/unicodeobject.rs: pub fn PyUnicode_AsEncodedUnicode(
It seems safe to remove these functions. methane commented on Apr 25, 2025 I am OK. But they are stable ABI. We need to convert them into abi only stable abi function that raise RuntimeError. vstinner commented on Apr 25, 2025
I am OK. But they are stable ABI. We need to convert them into abi only stable abi function that raise RuntimeError.
This change doesn't remove functions, it only schedules the removal.
For the API removal, we can keep the functions unchanged in the stable ABI. There is no need to raise RuntimeError. added a commit that references this issue on Apr 25, 2025gh-132798: Schedule removal of `PyUnicode_AsDecoded/Encoded` function…
MetadataMetadatainterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DevelopmentNo branches or pull requestsIssue actions
|