Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-99726-2
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba committed Mar 14, 2023
2 parents ce037f3 + a703f74 commit a7c6394
Show file tree
Hide file tree
Showing 87 changed files with 2,643 additions and 888 deletions.
33 changes: 33 additions & 0 deletions Doc/c-api/gcsupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,36 @@ garbage collection runs.
Returns the current state, 0 for disabled and 1 for enabled.
.. versionadded:: 3.10
Querying Garbage Collector State
--------------------------------
The C-API provides the following interface for querying information about
the garbage collector.
.. c:function:: void PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg)
Run supplied *callback* on all live GC-capable objects. *arg* is passed through to
all invocations of *callback*.
.. warning::
If new objects are (de)allocated by the callback it is undefined if they
will be visited.
Garbage collection is disabled during operation. Explicitly running a collection
in the callback may lead to undefined behaviour e.g. visiting the same objects
multiple times or not at all.
.. versionadded:: 3.12
.. c:type:: int (*gcvisitobjects_t)(PyObject *object, void *arg)
Type of the visitor function to be passed to :c:func:`PyUnstable_GC_VisitObjects`.
*arg* is the same as the *arg* passed to ``PyUnstable_GC_VisitObjects``.
Return ``0`` to continue iteration, return ``1`` to stop iteration. Other return
values are reserved for now so behavior on returning anything else is undefined.
.. versionadded:: 3.12
3 changes: 0 additions & 3 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,6 @@ Waiting Primitives
Raises :exc:`TimeoutError` if the timeout occurs before
all Futures are done.

.. versionchanged:: 3.10
Removed the *loop* parameter.

Example::

for coro in as_completed(aws):
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/base64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The modern interface provides:
This allows an application to e.g. generate URL or filesystem safe Base64
strings. The default is ``None``, for which the standard Base64 alphabet is used.

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


Expand Down
2 changes: 1 addition & 1 deletion Doc/library/concurrent.futures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ ThreadPoolExecutor Example
'http://www.cnn.com/',
'http://europe.wsj.com/',
'http://www.bbc.co.uk/',
'http://some-made-up-domain.com/']
'http://nonexistant-subdomain.python.org/']

# Retrieve a single page and report the URL and contents
def load_url(url, timeout):
Expand Down
6 changes: 5 additions & 1 deletion Doc/library/dataclasses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ Module contents
:func:`astuple` raises :exc:`TypeError` if ``obj`` is not a dataclass
instance.

.. 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)
.. 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)

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

If ``module`` is defined, the ``__module__`` attribute
of the dataclass is set to that value.
By default, it is set to the module name of the caller.

This function is not strictly required, because any Python
mechanism for creating a new class with ``__annotations__`` can
then apply the :func:`dataclass` function to convert that class to
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ the following command can be used to display the disassembly of
2 0 RESUME 0
<BLANKLINE>
3 2 LOAD_GLOBAL 1 (NULL + len)
14 LOAD_FAST 0 (alist)
16 CALL 1
26 RETURN_VALUE
12 LOAD_FAST 0 (alist)
14 CALL 1
24 RETURN_VALUE

(The "2" is a line number).

Expand Down
28 changes: 26 additions & 2 deletions Doc/library/inspect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1440,8 +1440,8 @@ code execution::
pass


Current State of Generators and Coroutines
------------------------------------------
Current State of Generators, Coroutines, and Asynchronous Generators
--------------------------------------------------------------------

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

.. versionadded:: 3.5

.. function:: getasyncgenstate(agen)

Get current state of an asynchronous generator object. The function is
intended to be used with asynchronous iterator objects created by
:keyword:`async def` functions which use the :keyword:`yield` statement,
but will accept any asynchronous generator-like object that has
``ag_running`` and ``ag_frame`` attributes.

Possible states are:
* AGEN_CREATED: Waiting to start execution.
* AGEN_RUNNING: Currently being executed by the interpreter.
* AGEN_SUSPENDED: Currently suspended at a yield expression.
* AGEN_CLOSED: Execution has completed.

.. versionadded:: 3.12

The current internal state of the generator can also be queried. This is
mostly useful for testing purposes, to ensure that internal state is being
updated as expected:
Expand Down Expand Up @@ -1507,6 +1523,14 @@ updated as expected:

.. versionadded:: 3.5

.. function:: getasyncgenlocals(agen)

This function is analogous to :func:`~inspect.getgeneratorlocals`, but
works for asynchronous generator objects created by :keyword:`async def`
functions which use the :keyword:`yield` statement.

.. versionadded:: 3.12


.. _inspect-module-co-flags:

Expand Down
63 changes: 63 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2188,6 +2188,69 @@ features:
Accepts a :term:`path-like object`.


.. function:: listdrives()

Return a list containing the names of drives on a Windows system.

A drive name typically looks like ``'C:\\'``. Not every drive name
will be associated with a volume, and some may be inaccessible for
a variety of reasons, including permissions, network connectivity
or missing media. This function does not test for access.

May raise :exc:`OSError` if an error occurs collecting the drive
names.

.. audit-event:: os.listdrives "" os.listdrives

.. availability:: Windows

.. versionadded:: 3.12


.. function:: listmounts(volume)

Return a list containing the mount points for a volume on a Windows
system.

*volume* must be represented as a GUID path, like those returned by
:func:`os.listvolumes`. Volumes may be mounted in multiple locations
or not at all. In the latter case, the list will be empty. Mount
points that are not associated with a volume will not be returned by
this function.

The mount points return by this function will be absolute paths, and
may be longer than the drive name.

Raises :exc:`OSError` if the volume is not recognized or if an error
occurs collecting the paths.

.. audit-event:: os.listmounts volume os.listmounts

.. availability:: Windows

.. versionadded:: 3.12


.. function:: listvolumes()

Return a list containing the volumes in the system.

Volumes are typically represented as a GUID path that looks like
``\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\``. Files can
usually be accessed through a GUID path, permissions allowing.
However, users are generally not familiar with them, and so the
recommended use of this function is to retrieve mount points
using :func:`os.listmounts`.

May raise :exc:`OSError` if an error occurs collecting the volumes.

.. audit-event:: os.listvolumes "" os.listvolumes

.. availability:: Windows

.. versionadded:: 3.12


.. function:: lstat(path, *, dir_fd=None)

Perform the equivalent of an :c:func:`lstat` system call on the given path.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ that.
It is safe to set these to false on any Python version. They will have no
effect on older versions when unsupported. Do not assume the attributes are
available to read. Despite their names, a true value does not indicate that the
corresponding function will be used, only that that it may be.
corresponding function will be used, only that it may be.

Please file issues any time you have to use these private knobs with a way to
reproduce the issue you were seeing. Link to that issue from a comment in your
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/threading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ The instance's values will be different for separate threads.
A class that represents thread-local data.

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


.. _thread-objects:
Expand Down
58 changes: 31 additions & 27 deletions Doc/library/turtle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ Appearance
will be displayed stretched according to its stretchfactors: *stretch_wid* is
stretchfactor perpendicular to its orientation, *stretch_len* is
stretchfactor in direction of its orientation, *outline* determines the width
of the shapes's outline.
of the shape's outline.

.. doctest::
:skipif: _tkinter is None
Expand Down Expand Up @@ -1545,7 +1545,7 @@ below:

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

For example:

Expand Down Expand Up @@ -2125,7 +2125,7 @@ Public classes

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

Provides screen oriented methods like :func:`setbg` etc. that are described
Provides screen oriented methods like :func:`bgcolor` etc. that are described
above.

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

The built in configuration would correspond to the following turtle.cfg::
The built in configuration would correspond to the following ``turtle.cfg``:

.. code-block:: ini
width = 0.5
height = 0.75
Expand All @@ -2340,15 +2342,15 @@ The built in configuration would correspond to the following turtle.cfg::
Short explanation of selected entries:

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

The demo scripts are:

.. currentmodule:: turtle

.. tabularcolumns:: |l|L|L|

+----------------+------------------------------+-----------------------+
Expand Down Expand Up @@ -2469,44 +2473,44 @@ Have fun!
Changes since Python 2.6
========================

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

- The method :meth:`Turtle.fill` has been eliminated.
The behaviour of :meth:`begin_fill` and :meth:`end_fill`
have changed slightly: now every filling-process must be completed with an
- The method :func:`!Turtle.fill` has been eliminated.
The behaviour of :func:`begin_fill` and :func:`end_fill`
have changed slightly: now every filling process must be completed with an
``end_fill()`` call.

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

Changes since Python 3.0
========================

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

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

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

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

- Two example scripts :file:`tdemo_nim.py` and :file:`tdemo_round_dance.py`
Expand Down
2 changes: 1 addition & 1 deletion Doc/reference/compound_stmts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ keyword against a subject. Syntax:

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

In simple terms ``P as NAME`` will match with ``P``, and on success it will
set ``NAME = <subject>``.
Expand Down
6 changes: 4 additions & 2 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1944,8 +1944,10 @@ Notes on using *__slots__*
descriptor directly from the base class). This renders the meaning of the
program undefined. In the future, a check may be added to prevent this.

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

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

Expand Down
Loading

0 comments on commit a7c6394

Please sign in to comment.