Skip to content

Commit 7dfd1ca

Browse files
committed
Merge branch 'main' into pythongh-115999-thread-local-bytecode
2 parents aa330b1 + 43979fa commit 7dfd1ca

File tree

132 files changed

+2637
-955
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+2637
-955
lines changed

.github/ISSUE_TEMPLATE/crash.yml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ body:
3232
- "3.10"
3333
- "3.11"
3434
- "3.12"
35+
- "3.13"
3536
- "CPython main branch"
3637
validations:
3738
required: true

Doc/c-api/exceptions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ Exception Classes
733733
This creates a class object derived from :exc:`Exception` (accessible in C as
734734
:c:data:`PyExc_Exception`).
735735
736-
The :attr:`!__module__` attribute of the new class is set to the first part (up
736+
The :attr:`~type.__module__` attribute of the new class is set to the first part (up
737737
to the last dot) of the *name* argument, and the class name is set to the last
738738
part (after the last dot). The *base* argument can be used to specify alternate
739739
base classes; it can either be only one class or a tuple of classes. The *dict*

Doc/c-api/long.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
570570
On failure, return -1 with an exception set. This function always succeeds
571571
if *obj* is a :c:type:`PyLongObject` or its subtype.
572572
573-
.. versionadded:: 3.14
573+
.. versionadded:: next
574574
575575
576576
.. c:function:: PyObject* PyLong_GetInfo(void)

Doc/c-api/object.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ Object Protocol
367367
The result will be ``1`` when at least one of the checks returns ``1``,
368368
otherwise it will be ``0``.
369369
370-
If *cls* has a :meth:`~class.__subclasscheck__` method, it will be called to
370+
If *cls* has a :meth:`~type.__subclasscheck__` method, it will be called to
371371
determine the subclass status as described in :pep:`3119`. Otherwise,
372372
*derived* is a subclass of *cls* if it is a direct or indirect subclass,
373-
i.e. contained in ``cls.__mro__``.
373+
i.e. contained in :attr:`cls.__mro__ <type.__mro__>`.
374374
375375
Normally only class objects, i.e. instances of :class:`type` or a derived
376376
class, are considered classes. However, objects can override this by having
377-
a :attr:`~class.__bases__` attribute (which must be a tuple of base classes).
377+
a :attr:`~type.__bases__` attribute (which must be a tuple of base classes).
378378
379379
380380
.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
@@ -386,15 +386,15 @@ Object Protocol
386386
The result will be ``1`` when at least one of the checks returns ``1``,
387387
otherwise it will be ``0``.
388388
389-
If *cls* has a :meth:`~class.__instancecheck__` method, it will be called to
389+
If *cls* has a :meth:`~type.__instancecheck__` method, it will be called to
390390
determine the subclass status as described in :pep:`3119`. Otherwise, *inst*
391391
is an instance of *cls* if its class is a subclass of *cls*.
392392
393393
An instance *inst* can override what is considered its class by having a
394-
:attr:`~instance.__class__` attribute.
394+
:attr:`~object.__class__` attribute.
395395
396396
An object *cls* can override if it is considered a class, and what its base
397-
classes are, by having a :attr:`~class.__bases__` attribute (which must be a tuple
397+
classes are, by having a :attr:`~type.__bases__` attribute (which must be a tuple
398398
of base classes).
399399
400400

Doc/c-api/type.rst

+10-8
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Type Objects
5353
.. c:function:: PyObject* PyType_GetDict(PyTypeObject* type)
5454
5555
Return the type object's internal namespace, which is otherwise only
56-
exposed via a read-only proxy (``cls.__dict__``). This is a
56+
exposed via a read-only proxy (:attr:`cls.__dict__ <type.__dict__>`).
57+
This is a
5758
replacement for accessing :c:member:`~PyTypeObject.tp_dict` directly.
5859
The returned dictionary must be treated as read-only.
5960
@@ -140,7 +141,7 @@ Type Objects
140141
Return true if *a* is a subtype of *b*.
141142
142143
This function only checks for actual subtypes, which means that
143-
:meth:`~class.__subclasscheck__` is not called on *b*. Call
144+
:meth:`~type.__subclasscheck__` is not called on *b*. Call
144145
:c:func:`PyObject_IsSubclass` to do the same check that :func:`issubclass`
145146
would do.
146147
@@ -174,29 +175,30 @@ Type Objects
174175
175176
.. c:function:: PyObject* PyType_GetName(PyTypeObject *type)
176177
177-
Return the type's name. Equivalent to getting the type's ``__name__`` attribute.
178+
Return the type's name. Equivalent to getting the type's
179+
:attr:`~type.__name__` attribute.
178180
179181
.. versionadded:: 3.11
180182
181183
.. c:function:: PyObject* PyType_GetQualName(PyTypeObject *type)
182184
183185
Return the type's qualified name. Equivalent to getting the
184-
type's ``__qualname__`` attribute.
186+
type's :attr:`~type.__qualname__` attribute.
185187
186188
.. versionadded:: 3.11
187189
188190
.. c:function:: PyObject* PyType_GetFullyQualifiedName(PyTypeObject *type)
189191
190192
Return the type's fully qualified name. Equivalent to
191-
``f"{type.__module__}.{type.__qualname__}"``, or ``type.__qualname__`` if
192-
``type.__module__`` is not a string or is equal to ``"builtins"``.
193+
``f"{type.__module__}.{type.__qualname__}"``, or :attr:`type.__qualname__`
194+
if :attr:`type.__module__` is not a string or is equal to ``"builtins"``.
193195
194196
.. versionadded:: 3.13
195197
196198
.. c:function:: PyObject* PyType_GetModuleName(PyTypeObject *type)
197199
198-
Return the type's module name. Equivalent to getting the ``type.__module__``
199-
attribute.
200+
Return the type's module name. Equivalent to getting the
201+
:attr:`type.__module__` attribute.
200202
201203
.. versionadded:: 3.13
202204

Doc/c-api/typeobj.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,12 @@ and :c:data:`PyType_Type` effectively act as defaults.)
567567

568568
For :ref:`statically allocated type objects <static-types>`,
569569
the *tp_name* field should contain a dot.
570-
Everything before the last dot is made accessible as the :attr:`__module__`
570+
Everything before the last dot is made accessible as the :attr:`~type.__module__`
571571
attribute, and everything after the last dot is made accessible as the
572-
:attr:`~definition.__name__` attribute.
572+
:attr:`~type.__name__` attribute.
573573

574574
If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is made accessible as the
575-
:attr:`~definition.__name__` attribute, and the :attr:`__module__` attribute is undefined
575+
:attr:`~type.__name__` attribute, and the :attr:`~type.__module__` attribute is undefined
576576
(unless explicitly set in the dictionary, as explained above). This means your
577577
type will be impossible to pickle. Additionally, it will not be listed in
578578
module documentations created with pydoc.
@@ -1131,7 +1131,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
11311131

11321132
.. c:macro:: Py_TPFLAGS_MANAGED_DICT
11331133
1134-
This bit indicates that instances of the class have a ``__dict__``
1134+
This bit indicates that instances of the class have a `~object.__dict__`
11351135
attribute, and that the space for the dictionary is managed by the VM.
11361136

11371137
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set.
@@ -1335,8 +1335,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
13351335
.. c:member:: const char* PyTypeObject.tp_doc
13361336
13371337
An optional pointer to a NUL-terminated C string giving the docstring for this
1338-
type object. This is exposed as the :attr:`__doc__` attribute on the type and
1339-
instances of the type.
1338+
type object. This is exposed as the :attr:`~type.__doc__` attribute on the
1339+
type and instances of the type.
13401340

13411341
**Inheritance:**
13421342

@@ -2036,7 +2036,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
20362036
A collection of subclasses. Internal use only. May be an invalid pointer.
20372037

20382038
To get a list of subclasses, call the Python method
2039-
:py:meth:`~class.__subclasses__`.
2039+
:py:meth:`~type.__subclasses__`.
20402040

20412041
.. versionchanged:: 3.12
20422042

Doc/c-api/unicode.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ PyUnicodeWriter
15341534
The :c:type:`PyUnicodeWriter` API can be used to create a Python :class:`str`
15351535
object.
15361536
1537-
.. versionadded:: 3.14
1537+
.. versionadded:: next
15381538
15391539
.. c:type:: PyUnicodeWriter
15401540

Doc/extending/newtypes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` table
296296
descriptors that are used at runtime is that any attribute defined this way can
297297
have an associated doc string simply by providing the text in the table. An
298298
application can use the introspection API to retrieve the descriptor from the
299-
class object, and get the doc string using its :attr:`!__doc__` attribute.
299+
class object, and get the doc string using its :attr:`~type.__doc__` attribute.
300300

301301
As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :c:member:`~PyMethodDef.ml_name` value
302302
of ``NULL`` is required.

Doc/extending/newtypes_tutorial.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ only used for variable-sized objects and should otherwise be zero.
144144
If you want your type to be subclassable from Python, and your type has the same
145145
:c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have problems with multiple
146146
inheritance. A Python subclass of your type will have to list your type first
147-
in its :attr:`~class.__bases__`, or else it will not be able to call your type's
147+
in its :attr:`~type.__bases__`, or else it will not be able to call your type's
148148
:meth:`~object.__new__` method without getting an error. You can avoid this problem by
149149
ensuring that your type has a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its
150150
base type does. Most of the time, this will be true anyway, because either your

Doc/faq/programming.rst

+10-3
Original file line numberDiff line numberDiff line change
@@ -1613,9 +1613,16 @@ method too, and it must do so carefully. The basic implementation of
16131613
self.__dict__[name] = value
16141614
...
16151615

1616-
Most :meth:`!__setattr__` implementations must modify
1617-
:meth:`self.__dict__ <object.__dict__>` to store
1618-
local state for self without causing an infinite recursion.
1616+
Many :meth:`~object.__setattr__` implementations call :meth:`!object.__setattr__` to set
1617+
an attribute on self without causing infinite recursion::
1618+
1619+
class X:
1620+
def __setattr__(self, name, value):
1621+
# Custom logic here...
1622+
object.__setattr__(self, name, value)
1623+
1624+
Alternatively, it is possible to set attributes by inserting
1625+
entries into :attr:`self.__dict__ <object.__dict__>` directly.
16191626

16201627

16211628
How do I call a method defined in a base class from a derived class that extends it?

Doc/glossary.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ Glossary
347347
docstring
348348
A string literal which appears as the first expression in a class,
349349
function or module. While ignored when the suite is executed, it is
350-
recognized by the compiler and put into the :attr:`!__doc__` attribute
350+
recognized by the compiler and put into the :attr:`~definition.__doc__` attribute
351351
of the enclosing class, function or module. Since it is available via
352352
introspection, it is the canonical place for documentation of the
353353
object.
@@ -1241,7 +1241,7 @@ Glossary
12411241
type
12421242
The type of a Python object determines what kind of object it is; every
12431243
object has a type. An object's type is accessible as its
1244-
:attr:`~instance.__class__` attribute or can be retrieved with
1244+
:attr:`~object.__class__` attribute or can be retrieved with
12451245
``type(obj)``.
12461246

12471247
type alias

Doc/howto/annotations.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ Your code will have to have a separate code path if the object
107107
you're examining is a class (``isinstance(o, type)``).
108108
In that case, best practice relies on an implementation detail
109109
of Python 3.9 and before: if a class has annotations defined,
110-
they are stored in the class's ``__dict__`` dictionary. Since
110+
they are stored in the class's :attr:`~type.__dict__` dictionary. Since
111111
the class may or may not have annotations defined, best practice
112-
is to call the ``get`` method on the class dict.
112+
is to call the :meth:`~dict.get` method on the class dict.
113113

114114
To put it all together, here is some sample code that safely
115115
accesses the ``__annotations__`` attribute on an arbitrary
@@ -126,8 +126,8 @@ the type of ``ann`` using :func:`isinstance` before further
126126
examination.
127127

128128
Note that some exotic or malformed type objects may not have
129-
a ``__dict__`` attribute, so for extra safety you may also wish
130-
to use :func:`getattr` to access ``__dict__``.
129+
a :attr:`~type.__dict__` attribute, so for extra safety you may also wish
130+
to use :func:`getattr` to access :attr:`!__dict__`.
131131

132132

133133
Manually Un-Stringizing Stringized Annotations
@@ -247,4 +247,5 @@ on the class, you may observe unexpected behavior; see
247247
quirks by using :func:`annotationlib.get_annotations` on Python 3.14+ or
248248
:func:`inspect.get_annotations` on Python 3.10+. On earlier versions of
249249
Python, you can avoid these bugs by accessing the annotations from the
250-
class's ``__dict__`` (e.g., ``cls.__dict__.get('__annotations__', None)``).
250+
class's :attr:`~type.__dict__`
251+
(e.g., ``cls.__dict__.get('__annotations__', None)``).

Doc/howto/descriptor.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,8 @@ attribute access.
562562

563563
The expression ``obj.x`` looks up the attribute ``x`` in the chain of
564564
namespaces for ``obj``. If the search finds a descriptor outside of the
565-
instance ``__dict__``, its :meth:`__get__` method is invoked according to the
566-
precedence rules listed below.
565+
instance :attr:`~object.__dict__`, its :meth:`~object.__get__` method is
566+
invoked according to the precedence rules listed below.
567567

568568
The details of invocation depend on whether ``obj`` is an object, class, or
569569
instance of super.

Doc/howto/enum.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ The solution is to specify the module name explicitly as follows::
608608
the source, pickling will be disabled.
609609

610610
The new pickle protocol 4 also, in some circumstances, relies on
611-
:attr:`~definition.__qualname__` being set to the location where pickle will be able
611+
:attr:`~type.__qualname__` being set to the location where pickle will be able
612612
to find the class. For example, if the class was made available in class
613613
SomeData in the global scope::
614614

0 commit comments

Comments
 (0)