Skip to content

Commit a7c6394

Browse files
committed
Merge branch 'main' into pythongh-99726-2
2 parents ce037f3 + a703f74 commit a7c6394

File tree

87 files changed

+2643
-888
lines changed

Some content is hidden

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

87 files changed

+2643
-888
lines changed

Doc/c-api/gcsupport.rst

+33
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,36 @@ garbage collection runs.
228228
Returns the current state, 0 for disabled and 1 for enabled.
229229
230230
.. versionadded:: 3.10
231+
232+
233+
Querying Garbage Collector State
234+
--------------------------------
235+
236+
The C-API provides the following interface for querying information about
237+
the garbage collector.
238+
239+
.. c:function:: void PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg)
240+
241+
Run supplied *callback* on all live GC-capable objects. *arg* is passed through to
242+
all invocations of *callback*.
243+
244+
.. warning::
245+
If new objects are (de)allocated by the callback it is undefined if they
246+
will be visited.
247+
248+
Garbage collection is disabled during operation. Explicitly running a collection
249+
in the callback may lead to undefined behaviour e.g. visiting the same objects
250+
multiple times or not at all.
251+
252+
.. versionadded:: 3.12
253+
254+
.. c:type:: int (*gcvisitobjects_t)(PyObject *object, void *arg)
255+
256+
Type of the visitor function to be passed to :c:func:`PyUnstable_GC_VisitObjects`.
257+
*arg* is the same as the *arg* passed to ``PyUnstable_GC_VisitObjects``.
258+
Return ``0`` to continue iteration, return ``1`` to stop iteration. Other return
259+
values are reserved for now so behavior on returning anything else is undefined.
260+
261+
.. versionadded:: 3.12
262+
263+

Doc/library/asyncio-task.rst

-3
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,6 @@ Waiting Primitives
814814
Raises :exc:`TimeoutError` if the timeout occurs before
815815
all Futures are done.
816816

817-
.. versionchanged:: 3.10
818-
Removed the *loop* parameter.
819-
820817
Example::
821818

822819
for coro in as_completed(aws):

Doc/library/base64.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The modern interface provides:
5858
This allows an application to e.g. generate URL or filesystem safe Base64
5959
strings. The default is ``None``, for which the standard Base64 alphabet is used.
6060

61-
May assert or raise a a :exc:`ValueError` if the length of *altchars* is not 2. Raises a
61+
May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2. Raises a
6262
:exc:`TypeError` if *altchars* is not a :term:`bytes-like object`.
6363

6464

Doc/library/concurrent.futures.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ ThreadPoolExecutor Example
202202
'http://www.cnn.com/',
203203
'http://europe.wsj.com/',
204204
'http://www.bbc.co.uk/',
205-
'http://some-made-up-domain.com/']
205+
'http://nonexistant-subdomain.python.org/']
206206

207207
# Retrieve a single page and report the URL and contents
208208
def load_url(url, timeout):

Doc/library/dataclasses.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ Module contents
389389
:func:`astuple` raises :exc:`TypeError` if ``obj`` is not a dataclass
390390
instance.
391391

392-
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)
392+
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False, module=None)
393393

394394
Creates a new dataclass with name ``cls_name``, fields as defined
395395
in ``fields``, base classes as given in ``bases``, and initialized
@@ -401,6 +401,10 @@ Module contents
401401
``match_args``, ``kw_only``, ``slots``, and ``weakref_slot`` have
402402
the same meaning as they do in :func:`dataclass`.
403403

404+
If ``module`` is defined, the ``__module__`` attribute
405+
of the dataclass is set to that value.
406+
By default, it is set to the module name of the caller.
407+
404408
This function is not strictly required, because any Python
405409
mechanism for creating a new class with ``__annotations__`` can
406410
then apply the :func:`dataclass` function to convert that class to

Doc/library/dis.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ the following command can be used to display the disassembly of
5757
2 0 RESUME 0
5858
<BLANKLINE>
5959
3 2 LOAD_GLOBAL 1 (NULL + len)
60-
14 LOAD_FAST 0 (alist)
61-
16 CALL 1
62-
26 RETURN_VALUE
60+
12 LOAD_FAST 0 (alist)
61+
14 CALL 1
62+
24 RETURN_VALUE
6363

6464
(The "2" is a line number).
6565

Doc/library/inspect.rst

+26-2
Original file line numberDiff line numberDiff line change
@@ -1440,8 +1440,8 @@ code execution::
14401440
pass
14411441

14421442

1443-
Current State of Generators and Coroutines
1444-
------------------------------------------
1443+
Current State of Generators, Coroutines, and Asynchronous Generators
1444+
--------------------------------------------------------------------
14451445

14461446
When implementing coroutine schedulers and for other advanced uses of
14471447
generators, it is useful to determine whether a generator is currently
@@ -1476,6 +1476,22 @@ generator to be determined easily.
14761476

14771477
.. versionadded:: 3.5
14781478

1479+
.. function:: getasyncgenstate(agen)
1480+
1481+
Get current state of an asynchronous generator object. The function is
1482+
intended to be used with asynchronous iterator objects created by
1483+
:keyword:`async def` functions which use the :keyword:`yield` statement,
1484+
but will accept any asynchronous generator-like object that has
1485+
``ag_running`` and ``ag_frame`` attributes.
1486+
1487+
Possible states are:
1488+
* AGEN_CREATED: Waiting to start execution.
1489+
* AGEN_RUNNING: Currently being executed by the interpreter.
1490+
* AGEN_SUSPENDED: Currently suspended at a yield expression.
1491+
* AGEN_CLOSED: Execution has completed.
1492+
1493+
.. versionadded:: 3.12
1494+
14791495
The current internal state of the generator can also be queried. This is
14801496
mostly useful for testing purposes, to ensure that internal state is being
14811497
updated as expected:
@@ -1507,6 +1523,14 @@ updated as expected:
15071523

15081524
.. versionadded:: 3.5
15091525

1526+
.. function:: getasyncgenlocals(agen)
1527+
1528+
This function is analogous to :func:`~inspect.getgeneratorlocals`, but
1529+
works for asynchronous generator objects created by :keyword:`async def`
1530+
functions which use the :keyword:`yield` statement.
1531+
1532+
.. versionadded:: 3.12
1533+
15101534

15111535
.. _inspect-module-co-flags:
15121536

Doc/library/os.rst

+63
Original file line numberDiff line numberDiff line change
@@ -2188,6 +2188,69 @@ features:
21882188
Accepts a :term:`path-like object`.
21892189

21902190

2191+
.. function:: listdrives()
2192+
2193+
Return a list containing the names of drives on a Windows system.
2194+
2195+
A drive name typically looks like ``'C:\\'``. Not every drive name
2196+
will be associated with a volume, and some may be inaccessible for
2197+
a variety of reasons, including permissions, network connectivity
2198+
or missing media. This function does not test for access.
2199+
2200+
May raise :exc:`OSError` if an error occurs collecting the drive
2201+
names.
2202+
2203+
.. audit-event:: os.listdrives "" os.listdrives
2204+
2205+
.. availability:: Windows
2206+
2207+
.. versionadded:: 3.12
2208+
2209+
2210+
.. function:: listmounts(volume)
2211+
2212+
Return a list containing the mount points for a volume on a Windows
2213+
system.
2214+
2215+
*volume* must be represented as a GUID path, like those returned by
2216+
:func:`os.listvolumes`. Volumes may be mounted in multiple locations
2217+
or not at all. In the latter case, the list will be empty. Mount
2218+
points that are not associated with a volume will not be returned by
2219+
this function.
2220+
2221+
The mount points return by this function will be absolute paths, and
2222+
may be longer than the drive name.
2223+
2224+
Raises :exc:`OSError` if the volume is not recognized or if an error
2225+
occurs collecting the paths.
2226+
2227+
.. audit-event:: os.listmounts volume os.listmounts
2228+
2229+
.. availability:: Windows
2230+
2231+
.. versionadded:: 3.12
2232+
2233+
2234+
.. function:: listvolumes()
2235+
2236+
Return a list containing the volumes in the system.
2237+
2238+
Volumes are typically represented as a GUID path that looks like
2239+
``\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\``. Files can
2240+
usually be accessed through a GUID path, permissions allowing.
2241+
However, users are generally not familiar with them, and so the
2242+
recommended use of this function is to retrieve mount points
2243+
using :func:`os.listmounts`.
2244+
2245+
May raise :exc:`OSError` if an error occurs collecting the volumes.
2246+
2247+
.. audit-event:: os.listvolumes "" os.listvolumes
2248+
2249+
.. availability:: Windows
2250+
2251+
.. versionadded:: 3.12
2252+
2253+
21912254
.. function:: lstat(path, *, dir_fd=None)
21922255

21932256
Perform the equivalent of an :c:func:`lstat` system call on the given path.

Doc/library/subprocess.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ that.
16221622
It is safe to set these to false on any Python version. They will have no
16231623
effect on older versions when unsupported. Do not assume the attributes are
16241624
available to read. Despite their names, a true value does not indicate that the
1625-
corresponding function will be used, only that that it may be.
1625+
corresponding function will be used, only that it may be.
16261626

16271627
Please file issues any time you have to use these private knobs with a way to
16281628
reproduce the issue you were seeing. Link to that issue from a comment in your

Doc/library/threading.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ The instance's values will be different for separate threads.
272272
A class that represents thread-local data.
273273

274274
For more details and extensive examples, see the documentation string of the
275-
:mod:`_threading_local` module.
275+
:mod:`_threading_local` module: :source:`Lib/_threading_local.py`.
276276

277277

278278
.. _thread-objects:

Doc/library/turtle.rst

+31-27
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ Appearance
12141214
will be displayed stretched according to its stretchfactors: *stretch_wid* is
12151215
stretchfactor perpendicular to its orientation, *stretch_len* is
12161216
stretchfactor in direction of its orientation, *outline* determines the width
1217-
of the shapes's outline.
1217+
of the shape's outline.
12181218

12191219
.. doctest::
12201220
:skipif: _tkinter is None
@@ -1545,7 +1545,7 @@ below:
15451545

15461546
1. Create an empty Shape object of type "compound".
15471547
2. Add as many components to this object as desired, using the
1548-
:meth:`addcomponent` method.
1548+
:meth:`~Shape.addcomponent` method.
15491549

15501550
For example:
15511551

@@ -2125,7 +2125,7 @@ Public classes
21252125

21262126
:param cv: a :class:`tkinter.Canvas`
21272127

2128-
Provides screen oriented methods like :func:`setbg` etc. that are described
2128+
Provides screen oriented methods like :func:`bgcolor` etc. that are described
21292129
above.
21302130

21312131
.. class:: Screen()
@@ -2315,7 +2315,9 @@ of this module or which better fits to your needs, e.g. for use in a classroom,
23152315
you can prepare a configuration file ``turtle.cfg`` which will be read at import
23162316
time and modify the configuration according to its settings.
23172317

2318-
The built in configuration would correspond to the following turtle.cfg::
2318+
The built in configuration would correspond to the following ``turtle.cfg``:
2319+
2320+
.. code-block:: ini
23192321
23202322
width = 0.5
23212323
height = 0.75
@@ -2340,15 +2342,15 @@ The built in configuration would correspond to the following turtle.cfg::
23402342
23412343
Short explanation of selected entries:
23422344

2343-
- The first four lines correspond to the arguments of the :meth:`Screen.setup`
2345+
- The first four lines correspond to the arguments of the :func:`Screen.setup <setup>`
23442346
method.
23452347
- Line 5 and 6 correspond to the arguments of the method
2346-
:meth:`Screen.screensize`.
2348+
:func:`Screen.screensize <screensize>`.
23472349
- *shape* can be any of the built-in shapes, e.g: arrow, turtle, etc. For more
23482350
info try ``help(shape)``.
2349-
- If you want to use no fillcolor (i.e. make the turtle transparent), you have
2351+
- If you want to use no fill color (i.e. make the turtle transparent), you have
23502352
to write ``fillcolor = ""`` (but all nonempty strings must not have quotes in
2351-
the cfg-file).
2353+
the cfg file).
23522354
- If you want to reflect the turtle its state, you have to use ``resizemode =
23532355
auto``.
23542356
- If you set e.g. ``language = italian`` the docstringdict
@@ -2398,6 +2400,8 @@ The :mod:`turtledemo` package directory contains:
23982400

23992401
The demo scripts are:
24002402

2403+
.. currentmodule:: turtle
2404+
24012405
.. tabularcolumns:: |l|L|L|
24022406

24032407
+----------------+------------------------------+-----------------------+
@@ -2469,44 +2473,44 @@ Have fun!
24692473
Changes since Python 2.6
24702474
========================
24712475

2472-
- The methods :meth:`Turtle.tracer`, :meth:`Turtle.window_width` and
2473-
:meth:`Turtle.window_height` have been eliminated.
2476+
- The methods :func:`Turtle.tracer <tracer>`, :func:`Turtle.window_width <window_width>` and
2477+
:func:`Turtle.window_height <window_height>` have been eliminated.
24742478
Methods with these names and functionality are now available only
24752479
as methods of :class:`Screen`. The functions derived from these remain
24762480
available. (In fact already in Python 2.6 these methods were merely
24772481
duplications of the corresponding
2478-
:class:`TurtleScreen`/:class:`Screen`-methods.)
2482+
:class:`TurtleScreen`/:class:`Screen` methods.)
24792483

2480-
- The method :meth:`Turtle.fill` has been eliminated.
2481-
The behaviour of :meth:`begin_fill` and :meth:`end_fill`
2482-
have changed slightly: now every filling-process must be completed with an
2484+
- The method :func:`!Turtle.fill` has been eliminated.
2485+
The behaviour of :func:`begin_fill` and :func:`end_fill`
2486+
have changed slightly: now every filling process must be completed with an
24832487
``end_fill()`` call.
24842488

2485-
- A method :meth:`Turtle.filling` has been added. It returns a boolean
2489+
- A method :func:`Turtle.filling <filling>` has been added. It returns a boolean
24862490
value: ``True`` if a filling process is under way, ``False`` otherwise.
24872491
This behaviour corresponds to a ``fill()`` call without arguments in
24882492
Python 2.6.
24892493

24902494
Changes since Python 3.0
24912495
========================
24922496

2493-
- The methods :meth:`Turtle.shearfactor`, :meth:`Turtle.shapetransform` and
2494-
:meth:`Turtle.get_shapepoly` have been added. Thus the full range of
2497+
- The :class:`Turtle` methods :func:`shearfactor`, :func:`shapetransform` and
2498+
:func:`get_shapepoly` have been added. Thus the full range of
24952499
regular linear transforms is now available for transforming turtle shapes.
2496-
:meth:`Turtle.tiltangle` has been enhanced in functionality: it now can
2497-
be used to get or set the tiltangle. :meth:`Turtle.settiltangle` has been
2500+
:func:`tiltangle` has been enhanced in functionality: it now can
2501+
be used to get or set the tilt angle. :func:`settiltangle` has been
24982502
deprecated.
24992503

2500-
- The method :meth:`Screen.onkeypress` has been added as a complement to
2501-
:meth:`Screen.onkey` which in fact binds actions to the keyrelease event.
2502-
Accordingly the latter has got an alias: :meth:`Screen.onkeyrelease`.
2504+
- The :class:`Screen` method :func:`onkeypress` has been added as a complement to
2505+
:func:`onkey`. As the latter binds actions to the key release event,
2506+
an alias: :func:`onkeyrelease` was also added for it.
25032507

2504-
- The method :meth:`Screen.mainloop` has been added. So when working only
2505-
with Screen and Turtle objects one must not additionally import
2506-
:func:`mainloop` anymore.
2508+
- The method :func:`Screen.mainloop <mainloop>` has been added,
2509+
so there is no longer a need to use the standalone :func:`mainloop` function
2510+
when working with :class:`Screen` and :class:`Turtle` objects.
25072511

2508-
- Two input methods has been added :meth:`Screen.textinput` and
2509-
:meth:`Screen.numinput`. These popup input dialogs and return
2512+
- Two input methods have been added: :func:`Screen.textinput <textinput>` and
2513+
:func:`Screen.numinput <numinput>`. These pop up input dialogs and return
25102514
strings and numbers respectively.
25112515

25122516
- Two example scripts :file:`tdemo_nim.py` and :file:`tdemo_round_dance.py`

Doc/reference/compound_stmts.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ keyword against a subject. Syntax:
816816

817817
If the OR pattern fails, the AS pattern fails. Otherwise, the AS pattern binds
818818
the subject to the name on the right of the as keyword and succeeds.
819-
``capture_pattern`` cannot be a a ``_``.
819+
``capture_pattern`` cannot be a ``_``.
820820

821821
In simple terms ``P as NAME`` will match with ``P``, and on success it will
822822
set ``NAME = <subject>``.

Doc/reference/datamodel.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -1944,8 +1944,10 @@ Notes on using *__slots__*
19441944
descriptor directly from the base class). This renders the meaning of the
19451945
program undefined. In the future, a check may be added to prevent this.
19461946

1947-
* Nonempty *__slots__* does not work for classes derived from "variable-length"
1948-
built-in types such as :class:`int`, :class:`bytes` and :class:`tuple`.
1947+
* :exc:`TypeError` will be raised if nonempty *__slots__* are defined for a
1948+
class derived from a
1949+
:c:member:`"variable-length" built-in type <PyTypeObject.tp_itemsize>` such as
1950+
:class:`int`, :class:`bytes`, and :class:`tuple`.
19491951

19501952
* Any non-string :term:`iterable` may be assigned to *__slots__*.
19511953

0 commit comments

Comments
 (0)