]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-46417: Cleanup typeobject.c code (GH-30795)
authorVictor Stinner <vstinner@python.org>
Sat, 22 Jan 2022 17:56:11 +0000 (18:56 +0100)
committerGitHub <noreply@github.com>
Sat, 22 Jan 2022 17:56:11 +0000 (18:56 +0100)
commit3a4c15bb9815b6f4652621fe6043ae18e0d202b3
tree4658c000ebbc51976c0e759859280bdb68d0eca4
parent500c146387b01ea797b52e6a54caf228384e184c
bpo-46417: Cleanup typeobject.c code (GH-30795)

* Add comment to recurse_down_subclasses() explaining why it's safe
  to use a borrowed reference to tp_subclasses.
* remove_all_subclasses() no longer accept NULL cases
* type_set_bases() now relies on the fact that new_bases is not NULL.
* type_dealloc_common() avoids PyErr_Fetch/PyErr_Restore if tp_bases
  is NULL.
* remove_all_subclasses() makes sure that no exception is raised.
* Don't test at runtime if tp_mro only contains types: rely on
  _PyType_CAST() assertion for that.
* _PyStaticType_Dealloc() no longer clears tp_subclasses which is
  already NULL.
* mro_hierarchy() avoids calling _PyType_GetSubclasses() if
  tp_subclasses is NULL.

Coding style:

* Use Py_NewRef().
* Add braces and move variable declarations to the first variable
  assignement.
* Rename a few variables and parameters to use better names.
Objects/typeobject.c