https://github.com/python/cpython/commit/d1eefcb1a56a3cbdff176553ae892a24cc47488b
commit: d1eefcb1a56a3cbdff176553ae892a24cc47488b
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: encukou <[email protected]>
date: 2026-07-29T15:33:08+02:00
summary:

[3.13] gh-62534: Document that three-argument type() does not call __prepare__ 
(GH-154028) (GH-154164)

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 5625b187ab528e10dcaa21726a7c95b110d97190)

Co-authored-by: soreavis <[email protected]>

files:
M Doc/library/functions.rst

diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index e7655449154a18..a42d0f338577f5 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -2091,6 +2091,11 @@ are always available.  They are listed here in 
alphabetical order.
    in the same way that keywords in a class
    definition (besides *metaclass*) would.
 
+   Unlike a :keyword:`class` statement, the three argument form does not
+   call the metaclass ``__prepare__`` method (see :ref:`prepare`).  Use
+   :func:`types.new_class` to dynamically create a class using the
+   appropriate metaclass.
+
    See also :ref:`class-customization`.
 
    .. versionchanged:: 3.6

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to