Skip to content

Commit

Permalink
What's New in Python 3.11: move C API changes (python#92390)
Browse files Browse the repository at this point in the history
Move C API changes to the C API > Porting to Python 3.11 section.
  • Loading branch information
vstinner authored May 9, 2022
1 parent 7b9803f commit d8104d1
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1501,37 +1501,6 @@ Build Changes
C API Changes
=============

* :c:func:`PyErr_SetExcInfo()` no longer uses the ``type`` and ``traceback``
arguments, the interpreter now derives those values from the exception
instance (the ``value`` argument). The function still steals references
of all three arguments.
(Contributed by Irit Katriel in :issue:`45711`.)

* :c:func:`PyErr_GetExcInfo()` now derives the ``type`` and ``traceback``
fields of the result from the exception instance (the ``value`` field).
(Contributed by Irit Katriel in :issue:`45711`.)

* :c:type:`_frozen` has a new ``is_package`` field to indicate whether
or not the frozen module is a package. Previously, a negative value
in the ``size`` field was the indicator. Now only non-negative values
be used for ``size``.
(Contributed by Kumar Aditya in :issue:`46608`.)

* :c:func:`_PyFrameEvalFunction` now takes ``_PyInterpreterFrame*``
as its second parameter, instead of ``PyFrameObject*``.
See :pep:`523` for more details of how to use this function pointer type.

* :c:func:`PyCode_New` and :c:func:`PyCode_NewWithPosOnlyArgs` now take
an additional ``exception_table`` argument.
Using these functions should be avoided, if at all possible.
To get a custom code object: create a code object using the compiler,
then get a modified version with the ``replace`` method.

* :c:type:`PyCodeObject` no longer has a ``co_code`` field. Instead,
use ``PyObject_GetAttrString(code_object, "co_code")`` or
:c:func:`PyCode_GetCode` to get the underlying bytes object.
(Contributed by Brandt Bucher in :issue:`46841` and Ken Jin in :gh:`92154`.)

New Features
------------

Expand Down Expand Up @@ -1598,6 +1567,37 @@ New Features
Porting to Python 3.11
----------------------

* :c:func:`PyErr_SetExcInfo()` no longer uses the ``type`` and ``traceback``
arguments, the interpreter now derives those values from the exception
instance (the ``value`` argument). The function still steals references
of all three arguments.
(Contributed by Irit Katriel in :issue:`45711`.)

* :c:func:`PyErr_GetExcInfo()` now derives the ``type`` and ``traceback``
fields of the result from the exception instance (the ``value`` field).
(Contributed by Irit Katriel in :issue:`45711`.)

* :c:type:`_frozen` has a new ``is_package`` field to indicate whether
or not the frozen module is a package. Previously, a negative value
in the ``size`` field was the indicator. Now only non-negative values
be used for ``size``.
(Contributed by Kumar Aditya in :issue:`46608`.)

* :c:func:`_PyFrameEvalFunction` now takes ``_PyInterpreterFrame*``
as its second parameter, instead of ``PyFrameObject*``.
See :pep:`523` for more details of how to use this function pointer type.

* :c:func:`PyCode_New` and :c:func:`PyCode_NewWithPosOnlyArgs` now take
an additional ``exception_table`` argument.
Using these functions should be avoided, if at all possible.
To get a custom code object: create a code object using the compiler,
then get a modified version with the ``replace`` method.

* :c:type:`PyCodeObject` no longer has a ``co_code`` field. Instead,
use ``PyObject_GetAttrString(code_object, "co_code")`` or
:c:func:`PyCode_GetCode` to get the underlying bytes object.
(Contributed by Brandt Bucher in :issue:`46841` and Ken Jin in :gh:`92154`.)

* The old trashcan macros (``Py_TRASHCAN_SAFE_BEGIN``/``Py_TRASHCAN_SAFE_END``)
are now deprecated. They should be replaced by the new macros
``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``.
Expand Down

0 comments on commit d8104d1

Please sign in to comment.