8000 gh-85275: Remove old buffer APIs by methane · Pull Request #105137 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-85275: Remove old buffer APIs #105137

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

Merged
merged 7 commits into from
Jun 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into remove-old-buffer-p…
…rotocol
  • Loading branch information
methane committed Jun 1, 2023
commit 9d3457419504fd618645adc0ca948ce8e7873690
36 changes: 36 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,39 @@ Removed
and ``PyObject_AsWriteBuffer()`` are removed. Please migrate to new buffer protocol;
:c:func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to elaborate how to replace the 3 "As" functions with PyObject_GetBuffer() flags? I'm not used this Py_buffer API. AsCharBuffer() use const char ** type and AsReadBuffer() use const void **buffer type: constant. But PyBuffer.buf type is void*, it's mutable. Maybe add a note about casting if needed? Or provide a full recipe. I don't know.

How do you replace buffer_len? Is it Py_buffer.len or Py_buffer.itemsize? It's a honest question, I don't know the answer :-(

You may also mention that PyObject_CheckReadBuffer() ignores any kind of exception, whereas PyObject_GetBuffer() can raise different exceptions. What is the expected exception if a type doesn't support the buffer protocol?

(Contributed by Inada Naoki in :gh:`85275`.

* Remove the following old functions to configure the Python initialization,
deprecated in Python 3.11:

* ``PySys_AddWarnOptionUnicode()``: use :c:member:`PyConfig.warnoptions` instead.
* ``PySys_AddWarnOption()``: use :c:member:`PyConfig.warnoptions` instead.
* ``PySys_AddXOption()``: use :c:member:`PyConfig.xoptions` instead.
* ``PySys_HasWarnOptions()``: use :c:member:`PyConfig.xoptions` instead.
* ``PySys_SetArgvEx()``: set :c:member:`PyConfig.argv` instead.
* ``PySys_SetArgv()``: set :c:member:`PyConfig.argv` instead.
* ``PySys_SetPath()``: set :c:member:`PyConfig.module_search_paths` instead.
* ``Py_SetPath()``: set :c:member:`PyConfig.module_search_paths` instead.
* ``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead.
* ``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead.
* ``Py_SetStandardStreamEncoding()``: set :c:member:`PyConfig.stdio_encoding` instead.
* ``_Py_SetProgramFullPath()``: set :c:member:`PyConfig.executable` instead.

Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization
Configuration <init-config>` instead (:pep:`587`), added to Python 3.8.
(Contributed by Victor Stinner in :gh:`105145`.)

* Remove ``PyEval_InitThreads()`` and ``PyEval_ThreadsInitialized()``
functions, deprecated in Python 3.9. Since Python 3.7, ``Py_Initialize()``
always creates the GIL: calling ``PyEval_InitThreads()`` did nothing and
``PyEval_ThreadsInitialized()`` always returned non-zero.
(Contributed by Victor Stinner in :gh:`105182`.)

* Remove ``PyEval_AcquireLock()`` and ``PyEval_ReleaseLock()`` functions,
deprecated in Python 3.2. They didn't update the current thread state.
They can be replaced with:

* :c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`;
* low-level :c:func:`PyEval_AcquireThread` and :c:func:`PyEval_RestoreThread`;
* or :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`.

(Contributed by Victor Stinner in :gh:`105182`.)
You are viewing a condensed version of this merge commit. You can view the full changes here.
0