Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C API] Deprecate private functions which have a public replacement #128863

Open
vstinner opened this issue Jan 15, 2025 · 3 comments
Open

[C API] Deprecate private functions which have a public replacement #128863

vstinner opened this issue Jan 15, 2025 · 3 comments
Labels
topic-C-API type-feature A feature request or enhancement

Comments

@vstinner
Copy link
Member

vstinner commented Jan 15, 2025

Hi,

Python 3.13 and 3.14 added public functions to replace private functions. For example, a public function PyBytes_Join() was added to replace the private function _PyBytes_Join().

I propose to deprecate the private functions which have a public replacement, and remove them in Python 3.16.

Victor

Linked PRs

vstinner added a commit to vstinner/cpython that referenced this issue Jan 15, 2025
* _PyBytes_Join()
* _PyThreadState_UncheckedGet()
* _Py_HashPointer()
* _Py_fopen_obj()

Replace _Py_HashPointer() with Py_HashPointer().
vstinner added a commit to vstinner/cpython that referenced this issue Jan 15, 2025
* _PyBytes_Join()
* _PyThreadState_UncheckedGet()
* _PyUnicode_AsString()
* _Py_HashPointer()
* _Py_fopen_obj()

Replace _Py_HashPointer() with Py_HashPointer().

Remove references to deprecated functions.
@vstinner
Copy link
Member Author

vstinner added a commit to vstinner/cpython that referenced this issue Jan 15, 2025
* _PyBytes_Join()
* _PyDict_GetItemStringWithError()
* _PyThreadState_UncheckedGet()
* _PyUnicode_AsString()
* _Py_HashPointer()
* _Py_fopen_obj()

Replace _Py_HashPointer() with Py_HashPointer().

Remove references to deprecated functions.
vstinner added a commit to vstinner/cpython that referenced this issue Jan 15, 2025
* _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.
vstinner added a commit to vstinner/cpython that referenced this issue Jan 15, 2025
* _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.
@vstinner
Copy link
Member Author

Other deprecations to consider:

  • _PyCode_GetExtra(): PyUnstable_Code_GetExtra()
  • _PyCode_SetExtra(): PyUnstable_Code_SetExtra()
  • _PyEval_RequestCodeExtraIndex(): PyUnstable_Eval_RequestCodeExtraIndex()
  • _PyLong_AsByteArray(): PyLong_AsNativeBytes()
  • _PyLong_FromByteArray(): PyLong_FromNativeBytes()
  • _PyLong_FromDigits(): PyLongWriter_Create()
  • _PyLong_New(): PyLongWriter_Create()
  • _PyLong_Sign(): PyLong_GetSign()
  • _PyUnicodeWriter_Init(): PyUnicodeWriter_Create() (and other _PyUnicodeWriter functions)

@picnixz picnixz added the type-feature A feature request or enhancement label Jan 17, 2025
vstinner added a commit that referenced this issue Jan 22, 2025
Deprecate private C API functions:

* _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.
vstinner added a commit to vstinner/cpython that referenced this issue Jan 22, 2025
Replace _PyLong_Sign() with PyLong_GetSign().
vstinner added a commit that referenced this issue Jan 23, 2025
Replace _PyLong_Sign() with PyLong_GetSign().
@skirpichev
Copy link
Member

I'm closing #127937 and #127936 in favor of this issue.

skirpichev added a commit to skirpichev/cpython that referenced this issue Jan 23, 2025
vstinner added a commit to vstinner/cpython that referenced this issue Jan 23, 2025
Deprecate private C API functions:

* _PyUnicodeWriter_Init()
* _PyUnicodeWriter_Finish()
* _PyUnicodeWriter_Dealloc()
* _PyUnicodeWriter_WriteChar()
* _PyUnicodeWriter_WriteStr()
* _PyUnicodeWriter_WriteSubstring()
* _PyUnicodeWriter_WriteASCIIString()
* _PyUnicodeWriter_WriteLatin1String()

These functions are not deprecated in the internal C API (if the
Py_BUILD_CORE macro is defined).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants