Skip to content

Commit f9f44dd

Browse files
[3.14] gh-62534: Document that three-argument type() does not call __prepare__ (GH-154028) (GH-154166)
The three-argument form of type() skips the metaclass __prepare__ method, which is called by the class statement machinery rather than by the metaclass call itself. Say so in the type() entry and point to types.new_class() for dynamic class creation with the appropriate metaclass, as directed in the issue thread. (cherry picked from commit 5625b18) Co-authored-by: soreavis <263610811+soreavis@users.noreply.github.com>
1 parent cb40934 commit f9f44dd

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Doc/library/functions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,11 @@ are always available. They are listed here in alphabetical order.
21102110
in the same way that keywords in a class
21112111
definition (besides *metaclass*) would.
21122112

2113+
Unlike a :keyword:`class` statement, the three argument form does not
2114+
call the metaclass ``__prepare__`` method (see :ref:`prepare`). Use
2115+
:func:`types.new_class` to dynamically create a class using the
2116+
appropriate metaclass.
2117+
21132118
See also :ref:`class-customization`.
21142119

21152120
.. versionchanged:: 3.6

0 commit comments

Comments
 (0)