FFFF Add Py_SETREF and Py_CLEAR operations by vstinner · Pull Request #56 · python/pythoncapi-compat · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Changelog
=========

* 2022-11-15: Add experimental operations to the upgrade_pythoncapi script:
``Py_INCREF_return``, ``Py_INCREF_assign``, ``Py_CLEAR`` and ``Py_SETREF``.
* 2022-11-09: Fix ``Py_SETREF()`` and ``Py_XSETREF()`` macros
for `gh-98724 <https://github.com/python/cpython/issues/98724>`_.
* 2022-11-04: Add ``PyFrame_GetVar()`` and ``PyFrame_GetVarString()``
Expand Down
28 changes: 28 additions & 0 deletions docs/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,31 @@ PyThreadState_GetFrame
----------------------

* Replace ``tstate->frame`` with ``_PyThreadState_GetFrameBorrow(tstate)``.

Experimental operations
-----------------------

The following operations are experimental (ex: can introduce compiler warnings)
and so not included in the ``all`` group, they have to be selected explicitly.
Example: ``-o all,Py_SETREF``.

Experimental operations:

* ``Py_INCREF_return``:

* Replace ``Py_INCREF(res); return res;`` with ``return Py_NewRef(res);``

* ``Py_INCREF_assign``:

* Replace ``x = y; Py_INCREF(x);`` with ``x = Py_NewRef(y);``
* Replace ``x = y; Py_INCREF(y);`` with ``x = Py_NewRef(y);``
* Replace ``Py_INCREF(y); x = y;`` with ``x = Py_NewRef(y);``

* ``Py_CLEAR``:

* Replace ``Py_XDECREF(var); var = NULL;`` with ``Py_CLEAR(var);``

* ``Py_SETREF``:

* Replace ``Py_DECREF(x); x = y;`` with ``Py_SETREF(x, y);``
* Replace ``Py_XDECREF(x); x = y;`` with ``Py_XSETREF(x, y);``
Loading
0