Skip to content

Commit

Permalink
Merge branch 'main' into remove-imp
Browse files Browse the repository at this point in the history
  • Loading branch information
warsaw committed Mar 11, 2023
2 parents c240e08 + 534660f commit f45d6a4
Show file tree
Hide file tree
Showing 267 changed files with 5,731 additions and 1,102 deletions.
17 changes: 14 additions & 3 deletions Doc/c-api/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,27 @@ bound into a function.
before the destruction of *co* takes place, so the prior state of *co*
can be inspected.
If *event* is ``PY_CODE_EVENT_DESTROY``, taking a reference in the callback
to the about-to-be-destroyed code object will resurrect it and prevent it
from being freed at this time. When the resurrected object is destroyed
later, any watcher callbacks active at that time will be called again.
Users of this API should not rely on internal runtime implementation
details. Such details may include, but are not limited to, the exact
order and timing of creation and destruction of code objects. While
changes in these details may result in differences observable by watchers
(including whether a callback is invoked or not), it does not change
the semantics of the Python code being executed.
If the callback returns with an exception set, it must return ``-1``; this
exception will be printed as an unraisable exception using
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
If the callback sets an exception, it must return ``-1``; this exception will
be printed as an unraisable exception using :c:func:`PyErr_WriteUnraisable`.
Otherwise it should return ``0``.
There may already be a pending exception set on entry to the callback. In
this case, the callback should return ``0`` with the same exception still
set. This means the callback may not call any other API that can set an
exception unless it saves and clears the exception state first, and restores
it before returning.
.. versionadded:: 3.12
Expand Down
21 changes: 17 additions & 4 deletions Doc/c-api/dict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,26 @@ Dictionary Objects
dictionary.
The callback may inspect but must not modify *dict*; doing so could have
unpredictable effects, including infinite recursion.
unpredictable effects, including infinite recursion. Do not trigger Python
code execution in the callback, as it could modify the dict as a side effect.
If *event* is ``PyDict_EVENT_DEALLOCATED``, taking a new reference in the
callback to the about-to-be-destroyed dictionary will resurrect it and
prevent it from being freed at this time. When the resurrected object is
destroyed later, any watcher callbacks active at that time will be called
again.
Callbacks occur before the notified modification to *dict* takes place, so
the prior state of *dict* can be inspected.
If the callback returns with an exception set, it must return ``-1``; this
exception will be printed as an unraisable exception using
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
If the callback sets an exception, it must return ``-1``; this exception will
be printed as an unraisable exception using :c:func:`PyErr_WriteUnraisable`.
Otherwise it should return ``0``.
There may already be a pending exception set on entry to the callback. In
this case, the callback should return ``0`` with the same exception still
set. This means the callback may not call any other API that can set an
exception unless it saves and clears the exception state first, and restores
it before returning.
.. versionadded:: 3.12
17 changes: 14 additions & 3 deletions Doc/c-api/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,19 @@ There are a few functions specific to Python functions.
runtime behavior depending on optimization decisions, it does not change
the semantics of the Python code being executed.
If the callback returns with an exception set, it must return ``-1``; this
exception will be printed as an unraisable exception using
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the
callback to the about-to-be-destroyed function will resurrect it, preventing
it from being freed at this time. When the resurrected object is destroyed
later, any watcher callbacks active at that time will be called again.
If the callback sets an exception, it must return ``-1``; this exception will
be printed as an unraisable exception using :c:func:`PyErr_WriteUnraisable`.
Otherwise it should return ``0``.
There may already be a pending exception set on entry to the callback. In
this case, the callback should return ``0`` with the same exception still
set. This means the callback may not call any other API that can set an
exception unless it saves and clears the exception state first, and restores
it before returning.
.. versionadded:: 3.12
3 changes: 1 addition & 2 deletions Doc/distributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ Key terms
developers and documentation authors responsible for the maintenance and
evolution of the standard packaging tools and the associated metadata and
file format standards. They maintain a variety of tools, documentation
and issue trackers on both `GitHub <https://github.com/pypa>`__ and
`Bitbucket <https://bitbucket.org/pypa/>`__.
and issue trackers on `GitHub <https://github.com/pypa>`__.
* ``distutils`` is the original build and distribution system first added
to the Python standard library in 1998. While direct use of ``distutils``
is being phased out, it still laid the foundation for the current packaging
Expand Down
3 changes: 1 addition & 2 deletions Doc/installing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ Key terms
developers and documentation authors responsible for the maintenance and
evolution of the standard packaging tools and the associated metadata and
file format standards. They maintain a variety of tools, documentation,
and issue trackers on both `GitHub <https://github.com/pypa>`__ and
`Bitbucket <https://bitbucket.org/pypa/>`__.
and issue trackers on `GitHub <https://github.com/pypa>`__.
* ``distutils`` is the original build and distribution system first added to
the Python standard library in 1998. While direct use of ``distutils`` is
being phased out, it still laid the foundation for the current packaging
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ around an instance of :class:`argparse.ArgumentParser`. It is a container for
argument specifications and has options that apply to the parser as whole::

parser = argparse.ArgumentParser(
prog = 'ProgramName',
description = 'What the program does',
epilog = 'Text at the bottom of help')
prog='ProgramName',
description='What the program does',
epilog='Text at the bottom of help')

The :meth:`ArgumentParser.add_argument` method attaches individual argument
specifications to the parser. It supports positional arguments, options that
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/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
2 changes: 1 addition & 1 deletion Doc/library/venv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ subclass which installs setuptools and pip into a created virtual environment::
:param context: The information for the virtual environment
creation request being processed.
"""
url = 'https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py'
url = "https://bootstrap.pypa.io/ez_setup.py"
self.install_script(context, 'setuptools', url)
# clear up the setuptools archive which gets downloaded
pred = lambda o: o.startswith('setuptools-') and o.endswith('.tar.gz')
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/zipapp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ using the :func:`create_archive` function::
>>> import zipapp
>>> zipapp.create_archive('old_archive.pyz', 'new_archive.pyz', '/usr/bin/python3')

To update the file in place, do the replacement in memory using a :class:`BytesIO`
To update the file in place, do the replacement in memory using a :class:`~io.BytesIO`
object, and then overwrite the source afterwards. Note that there is a risk
when overwriting a file in place that an error will result in the loss of
the original file. This code does not protect against such errors, but
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/zipfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ ZipFile Objects
(``ZipExtFile``) is read-only and provides the following methods:
:meth:`~io.BufferedIOBase.read`, :meth:`~io.IOBase.readline`,
:meth:`~io.IOBase.readlines`, :meth:`~io.IOBase.seek`,
:meth:`~io.IOBase.tell`, :meth:`__iter__`, :meth:`~iterator.__next__`.
:meth:`~io.IOBase.tell`, :meth:`~container.__iter__`, :meth:`~iterator.__next__`.
These objects can operate independently of the ZipFile.

With ``mode='w'``, a writable file handle is returned, which supports the
Expand Down
10 changes: 10 additions & 0 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ Other Language Changes
part of comprehensions (like ``a``) is still disallowed, as per :pep:`572`.
(Contributed by Nikita Sobolev in :gh:`100581`.)

* :class:`slice` objects are now hashable, allowing them to be used as dict keys and
set items. (Contributed by Furkan Onder in :gh:`101264`.)

New Modules
===========
Expand Down Expand Up @@ -242,6 +244,10 @@ inspect
a :term:`coroutine` for use with :func:`iscoroutinefunction`.
(Contributed Carlton Gibson in :gh:`99247`.)

* Add :func:`inspect.getasyncgenstate` and :func:`inspect.getasyncgenlocals`
for determining the current state of asynchronous generators.
(Contributed by Thomas Krennwallner in :issue:`35759`.)

pathlib
-------

Expand Down Expand Up @@ -292,6 +298,10 @@ os
method to check if the entry is a junction.
(Contributed by Charles Machalow in :gh:`99547`.)

* Add :func:`os.listdrives`, :func:`os.listvolumes` and :func:`os.listmounts`
functions on Windows for enumerating drives, volumes and mount points.
(Contributed by Steve Dower in :gh:`102519`.)

os.path
-------

Expand Down
13 changes: 9 additions & 4 deletions Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,14 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);

PyAPI_FUNC(int) PyCode_Addr2Location(PyCodeObject *, int, int *, int *, int *, int *);

typedef enum PyCodeEvent {
PY_CODE_EVENT_CREATE,
PY_CODE_EVENT_DESTROY
#define PY_FOREACH_CODE_EVENT(V) \
V(CREATE) \
V(DESTROY)

typedef enum {
#define PY_DEF_EVENT(op) PY_CODE_EVENT_##op,
PY_FOREACH_CODE_EVENT(PY_DEF_EVENT)
#undef PY_DEF_EVENT
} PyCodeEvent;


Expand All @@ -236,7 +241,7 @@ typedef enum PyCodeEvent {
* The callback is invoked with a borrowed reference to co, after it is
* created and before it is destroyed.
*
* If the callback returns with an exception set, it must return -1. Otherwise
* If the callback sets an exception, it must return -1. Otherwise
* it should return 0.
*/
typedef int (*PyCode_WatchCallback)(
Expand Down
Loading

0 comments on commit f45d6a4

Please sign in to comment.