gh-128863: Deprecate private C API functions#128864
Conversation
37869e2 to
18f8581
Compare
* _PyBytes_Join() * _PyDict_GetItemStringWithError() * _PyDict_Pop() * _PyThreadState_UncheckedGet() * _PyUnicode_AsString() * _Py_HashPointer() * _Py_fopen_obj() Replace _Py_HashPointer() with Py_HashPointer(). Remove references to deprecated functions.
18f8581 to
8140437
Compare
|
This is extra work for both you and for users. I do not see how this would reduce our maintenance burden. I also don't see any other benefit of this PR. |
|
Removing them from Python 3.16 seems a little hurried. Unless there is a specific reason to remove it sooner, how about schedule it for removal in Python 3.18? |
|
Code search on PyPI top 7,500 projects (2024-10-16). _PyBytes_Join(): 4 projects
_PyDict_GetItemStringWithError(): 3 projects
_PyDict_Pop(): 1 project
_PyThreadState_UncheckedGet(): 25 projects
_PyUnicode_AsString(): 1 project
_Py_HashPointer(): 3 projects
_Py_fopen_obj(): 1 project
I ignored projects including copies of these dependencies such as pybind11 copies. Total: 33 projects Affected projects (33):
|
I'm fine with using a longer deprecation period for Other functions are used by less than 5 projects and so can use a faster deprecation period, no? |
Python 3.13 will reach EOL in 2029. I want to keep it until 2031 (2029+2).
Python 3.12 will reach EOL in 2028. I want to keep it until 2030 (2028+2). Removing _PyUnicode_AsString with minimum deprecation period is OK because PyUnicode_AsUTF8 is added in 3.3. |
I updated my PR to postpone the removal to Python 3.18. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
I am not sure that it is worth to go such far in preserving compatibility for private C API. Usually we just changed it at will, it was a fair play.
Misc/NEWS.d/next/C_API/2025-01-15-11-42-07.gh-issue-128863.C9MkB_.rst
Outdated
Show resolved
Hide resolved
Do you suggest to remove these functions earlier? |
|
Were not some of them already removed? This is only my grumbling. I would remove them without warning if there is a replacement. You have to ask other core developers if they have reasons to keep the old private C API. Removing a private C API is not the worst thing that can be happen if you use private C API. It can change semantic -- start returning a strong reference instead of a weak reference or vice versa, start stealing a reference, change the order of parameters, etc. But if keep them -- your PR LGTM. |
|
Merged, thanks for review. |
Replace _Py_HashPointer() with Py_HashPointer().
Remove references to deprecated functions.
📚 Documentation preview 📚: https://cpython-previews--128864.org.readthedocs.build/