]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-144330: Initialize classmethod and staticmethod in new (#144469)
authorVictor Stinner <vstinner@python.org>
Thu, 5 Feb 2026 10:32:56 +0000 (11:32 +0100)
committerGitHub <noreply@github.com>
Thu, 5 Feb 2026 10:32:56 +0000 (11:32 +0100)
commitffa68529b40210d4c55ad3a4114e48007ae0e55a
treefbf2be5cab9376835186a7a570f8525498373c59
parentb53fc7caa6f41bf3bd7df7d2bd947cbbe670c352
gh-144330: Initialize classmethod and staticmethod in new (#144469)

Move classmethod and staticmethod initialization from __init__() to
__new__().

PyClassMethod_New() and PyStaticMethod_New() now copy attributes of
the wrapped functions: __module__, __name__, __qualname__ and
__doc__.

Change static type initialization: initialize PyStaticMethod_Type and
PyCFunction_Type earlier.

Remove test_refleaks_in_classmethod___init__() and
test_refleaks_in_staticmethod___init__() tests from test_descr since
classmethod and staticmethod have no __init__() method anymore.
Lib/test/test_descr.py
Misc/NEWS.d/next/Core_and_Builtins/2026-02-04-11-19-45.gh-issue-144330.kOowSb.rst [new file with mode: 0644]
Objects/funcobject.c
Objects/object.c