Skip to content

Schedule removal of PyUnicode_AsDecoded/Encoded functions #132798

Closed

Description

@StanFromIreland
  • 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

Activity

  1. hugovk commented on Apr 22, 2025

    @hugovk
    Member

    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/.

  2. StanFromIreland commented on Apr 22, 2025

    @StanFromIreland
    MemberAuthor

    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.)

  3. vstinner commented on Apr 22, 2025

    @vstinner
    Member

    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.

  4. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    type-bugAn unexpected behavior, bug, or error
    on Apr 24, 2025
  5. methane commented on Apr 25, 2025

    @methane
    Member

    I am OK. But they are stable ABI. We need to convert them into abi only stable abi function that raise RuntimeError.

  6. vstinner commented on Apr 25, 2025

    @vstinner
    Member

    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.

  7. added a commit that references this issue on Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions