Skip to content

Commit

Permalink
Merge branch 'main' into issue-101703
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Apr 27, 2023
2 parents 3e8e61f + dff8e5d commit d82e315
Show file tree
Hide file tree
Showing 184 changed files with 3,444 additions and 1,209 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ ENV WASMTIME_HOME=/opt/wasmtime
ENV WASMTIME_VERSION=7.0.0
ENV WASMTIME_CPU_ARCH=x86_64

RUN dnf -y --nodocs install git clang xz python3-blurb dnf-plugins-core && \
dnf -y --nodocs builddep python3 && \
RUN dnf -y --nodocs --setopt=install_weak_deps=False install /usr/bin/{blurb,clang,curl,git,ln,tar,xz} 'dnf-command(builddep)' && \
dnf -y --nodocs --setopt=install_weak_deps=False builddep python3 && \
dnf -y clean all

RUN mkdir ${WASI_SDK_PATH} && \
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
configure* @erlend-aasland @corona10

# asyncio
**/*asyncio* @1st1 @asvetlov @gvanrossum @kumaraditya303
**/*asyncio* @1st1 @asvetlov @gvanrossum @kumaraditya303 @willingc

# Core
**/*context* @1st1
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ jobs:
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Install Dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Set up GCC-10 for ASAN
uses: egor-tensin/setup-gcc@v1
with:
version: 10
- name: Configure OpenSSL env vars
run: |
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ jobs:

# Add pull request annotations for Sphinx nitpicks (missing references)
- name: 'Get list of changed files'
if: github.event_name == 'pull_request'
id: changed_files
uses: Ana06/[email protected]
with:
filter: "Doc/**"
- name: 'Build changed files in nit-picky mode'
if: github.event_name == 'pull_request'
continue-on-error: true
run: |
# Mark files the pull request modified
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/require-pr-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
label:
name: DO-NOT-MERGE
name: DO-NOT-MERGE / unresolved review
runs-on: ubuntu-latest
timeout-minutes: 10

Expand All @@ -15,4 +15,4 @@ jobs:
with:
mode: exactly
count: 0
labels: "DO-NOT-MERGE"
labels: "DO-NOT-MERGE, awaiting changes, awaiting change review"
9 changes: 9 additions & 0 deletions Doc/c-api/type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ Type Objects
.. versionadded:: 3.11
.. c:function:: int PyUnstable_Type_AssignVersionTag(PyTypeObject *type)
Attempt to assign a version tag to the given type.
Returns 1 if the type already had a valid version tag or a new one was
assigned, or 0 if a new tag could not be assigned.
.. versionadded:: 3.12
Creating Heap-Allocated Types
.............................
Expand Down
18 changes: 9 additions & 9 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,15 @@ APIs:
arguments.
.. c:function:: PyObject* PyUnicode_FromObject(PyObject *obj)
Copy an instance of a Unicode subtype to a new true Unicode object if
necessary. If *obj* is already a true Unicode object (not a subtype),
return the reference with incremented refcount.
Objects other than Unicode or its subtypes will cause a :exc:`TypeError`.
.. c:function:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, \
const char *encoding, const char *errors)
Expand Down Expand Up @@ -616,15 +625,6 @@ APIs:
.. versionadded:: 3.3
.. c:function:: PyObject* PyUnicode_FromObject(PyObject *obj)
Copy an instance of a Unicode subtype to a new true Unicode object if
necessary. If *obj* is already a true Unicode object (not a subtype),
return the reference with incremented refcount.
Objects other than Unicode or its subtypes will cause a :exc:`TypeError`.
Locale Encoding
"""""""""""""""
Expand Down
7 changes: 7 additions & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
if venvdir is not None:
exclude_patterns.append(venvdir + '/*')

nitpick_ignore = [
# Do not error nit-picky mode builds when _SubParsersAction.add_parser cannot
# be resolved, as the method is currently undocumented. For context, see
# https://github.com/python/cpython/pull/103289.
('py:meth', '_SubParsersAction.add_parser'),
]

# Disable Docutils smartquotes for several translations
smartquotes_excludes = {
'languages': ['ja', 'fr', 'zh_TW', 'zh_CN'], 'builders': ['man', 'text'],
Expand Down
29 changes: 29 additions & 0 deletions Doc/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# We have upper bounds on our transitive dependencies here
# To avoid new releases unexpectedly breaking our build.
# This file can be updated on an ad-hoc basis,
# though it will probably have to be updated
# whenever Doc/requirements.txt is updated.

# Direct dependencies of Sphinx
babel<3
colorama<0.5
imagesize<1.5
Jinja2<3.2
packaging<24
# Pygments==2.15.0 breaks CI
Pygments<2.16,!=2.15.0
requests<3
snowballstemmer<3
sphinxcontrib-applehelp<1.1
sphinxcontrib-devhelp<1.1
sphinxcontrib-htmlhelp<2.1
sphinxcontrib-jsmath<1.1
sphinxcontrib-qthelp<1.1
sphinxcontrib-serializinghtml<1.2

# Direct dependencies of Jinja2 (Jinja is a dependency of Sphinx, see above)
MarkupSafe<2.2

# Direct dependencies of sphinx-lint
polib<1.3
regex<2024
2 changes: 1 addition & 1 deletion Doc/extending/newtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ Here is an example::
}

PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%.400s'",
"'%.100s' object has no attribute '%.400s'",
tp->tp_name, name);
return NULL;
}
Expand Down
16 changes: 9 additions & 7 deletions Doc/howto/argparse.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
.. _argparse-tutorial:

*****************
Argparse Tutorial
*****************

:author: Tshepang Mbambo

.. _argparse-tutorial:
.. currentmodule:: argparse

This tutorial is intended to be a gentle introduction to :mod:`argparse`, the
recommended command-line parsing module in the Python standard library.

.. note::

There are two other modules that fulfill the same task, namely
:mod:`getopt` (an equivalent for :c:func:`getopt` from the C
:mod:`getopt` (an equivalent for ``getopt()`` from the C
language) and the deprecated :mod:`optparse`.
Note also that :mod:`argparse` is based on :mod:`optparse`,
and therefore very similar in terms of usage.
Expand Down Expand Up @@ -137,13 +139,13 @@ And running the code:
Here is what's happening:

* We've added the :meth:`add_argument` method, which is what we use to specify
* We've added the :meth:`~ArgumentParser.add_argument` method, which is what we use to specify
which command-line options the program is willing to accept. In this case,
I've named it ``echo`` so that it's in line with its function.

* Calling our program now requires us to specify an option.

* The :meth:`parse_args` method actually returns some data from the
* The :meth:`~ArgumentParser.parse_args` method actually returns some data from the
options specified, in this case, ``echo``.

* The variable is some form of 'magic' that :mod:`argparse` performs for free
Expand Down Expand Up @@ -256,7 +258,7 @@ Here is what is happening:

* To show that the option is actually optional, there is no error when running
the program without it. Note that by default, if an optional argument isn't
used, the relevant variable, in this case :attr:`args.verbosity`, is
used, the relevant variable, in this case ``args.verbosity``, is
given ``None`` as a value, which is the reason it fails the truth
test of the :keyword:`if` statement.

Expand Down Expand Up @@ -299,7 +301,7 @@ Here is what is happening:
We even changed the name of the option to match that idea.
Note that we now specify a new keyword, ``action``, and give it the value
``"store_true"``. This means that, if the option is specified,
assign the value ``True`` to :data:`args.verbose`.
assign the value ``True`` to ``args.verbose``.
Not specifying it implies ``False``.

* It complains when you specify a value, in true spirit of what flags
Expand Down Expand Up @@ -698,7 +700,7 @@ Conflicting options

So far, we have been working with two methods of an
:class:`argparse.ArgumentParser` instance. Let's introduce a third one,
:meth:`add_mutually_exclusive_group`. It allows for us to specify options that
:meth:`~ArgumentParser.add_mutually_exclusive_group`. It allows for us to specify options that
conflict with each other. Let's also change the rest of the program so that
the new functionality makes more sense:
we'll introduce the ``--quiet`` option,
Expand Down
26 changes: 20 additions & 6 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ arguments will never be treated as file references.

.. versionchanged:: 3.12
:class:`ArgumentParser` changed encoding and errors to read arguments files
from default (e.g. :func:`locale.getpreferredencoding(False)` and
from default (e.g. :func:`locale.getpreferredencoding(False) <locale.getpreferredencoding>` and
``"strict"``) to :term:`filesystem encoding and error handler`.
Arguments file should be encoded in UTF-8 instead of ANSI Codepage on Windows.

Expand Down Expand Up @@ -1191,7 +1191,7 @@ done downstream after the arguments are parsed.
For example, JSON or YAML conversions have complex error cases that require
better reporting than can be given by the ``type`` keyword. A
:exc:`~json.JSONDecodeError` would not be well formatted and a
:exc:`FileNotFound` exception would not be handled at all.
:exc:`FileNotFoundError` exception would not be handled at all.

Even :class:`~argparse.FileType` has its limitations for use with the ``type``
keyword. If one argument uses *FileType* and then a subsequent argument fails,
Expand Down Expand Up @@ -1445,7 +1445,7 @@ Action classes
Action classes implement the Action API, a callable which returns a callable
which processes arguments from the command-line. Any object which follows
this API may be passed as the ``action`` parameter to
:meth:`add_argument`.
:meth:`~ArgumentParser.add_argument`.

.. class:: Action(option_strings, dest, nargs=None, const=None, default=None, \
type=None, choices=None, required=False, help=None, \
Expand Down Expand Up @@ -1723,7 +1723,7 @@ Sub-commands
:class:`ArgumentParser` supports the creation of such sub-commands with the
:meth:`add_subparsers` method. The :meth:`add_subparsers` method is normally
called with no arguments and returns a special action object. This object
has a single method, :meth:`~ArgumentParser.add_parser`, which takes a
has a single method, :meth:`~_SubParsersAction.add_parser`, which takes a
command name and any :class:`ArgumentParser` constructor arguments, and
returns an :class:`ArgumentParser` object that can be modified as usual.

Expand Down Expand Up @@ -1789,7 +1789,7 @@ Sub-commands
for that particular parser will be printed. The help message will not
include parent parser or sibling parser messages. (A help message for each
subparser command, however, can be given by supplying the ``help=`` argument
to :meth:`add_parser` as above.)
to :meth:`~_SubParsersAction.add_parser` as above.)

::

Expand Down Expand Up @@ -2157,7 +2157,7 @@ the populated namespace and the list of remaining argument strings.

.. warning::
:ref:`Prefix matching <prefix-matching>` rules apply to
:meth:`parse_known_args`. The parser may consume an option even if it's just
:meth:`~ArgumentParser.parse_known_args`. The parser may consume an option even if it's just
a prefix of one of its known options, instead of leaving it in the remaining
arguments list.

Expand Down Expand Up @@ -2295,3 +2295,17 @@ A partial upgrade path from :mod:`optparse` to :mod:`argparse`:

* Replace the OptionParser constructor ``version`` argument with a call to
``parser.add_argument('--version', action='version', version='<the version>')``.

Exceptions
----------

.. exception:: ArgumentError

An error from creating or using an argument (optional or positional).

The string value of this exception is the message, augmented with
information about the argument that caused it.

.. exception:: ArgumentTypeError

Raised when something goes wrong converting a command line string to a type.
22 changes: 11 additions & 11 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1438,9 +1438,7 @@ async/await code consider using the high-level

* *stdin* can be any of these:

* a file-like object representing a pipe to be connected to the
subprocess's standard input stream using
:meth:`~loop.connect_write_pipe`
* a file-like object
* the :const:`subprocess.PIPE` constant (default) which will create a new
pipe and connect it,
* the value ``None`` which will make the subprocess inherit the file
Expand All @@ -1450,9 +1448,7 @@ async/await code consider using the high-level

* *stdout* can be any of these:

* a file-like object representing a pipe to be connected to the
subprocess's standard output stream using
:meth:`~loop.connect_write_pipe`
* a file-like object
* the :const:`subprocess.PIPE` constant (default) which will create a new
pipe and connect it,
* the value ``None`` which will make the subprocess inherit the file
Expand All @@ -1462,9 +1458,7 @@ async/await code consider using the high-level

* *stderr* can be any of these:

* a file-like object representing a pipe to be connected to the
subprocess's standard error stream using
:meth:`~loop.connect_write_pipe`
* a file-like object
* the :const:`subprocess.PIPE` constant (default) which will create a new
pipe and connect it,
* the value ``None`` which will make the subprocess inherit the file
Expand All @@ -1483,6 +1477,11 @@ async/await code consider using the high-level
as text. :func:`bytes.decode` can be used to convert the bytes returned
from the stream to text.

If a file-like object passed as *stdin*, *stdout* or *stderr* represents a
pipe, then the other side of this pipe should be registered with
:meth:`~loop.connect_write_pipe` or :meth:`~loop.connect_read_pipe` for use
with the event loop.

See the constructor of the :class:`subprocess.Popen` class
for documentation on other arguments.

Expand Down Expand Up @@ -1571,7 +1570,7 @@ Server objects are created by :meth:`loop.create_server`,
:meth:`loop.create_unix_server`, :func:`start_server`,
and :func:`start_unix_server` functions.

Do not instantiate the class directly.
Do not instantiate the :class:`Server` class directly.

.. class:: Server

Expand Down Expand Up @@ -1662,7 +1661,8 @@ Do not instantiate the class directly.

.. attribute:: sockets

List of :class:`socket.socket` objects the server is listening on.
List of socket-like objects, ``asyncio.trsock.TransportSocket``, which
the server is listening on.

.. versionchanged:: 3.7
Prior to Python 3.7 ``Server.sockets`` used to return an
Expand Down
7 changes: 7 additions & 0 deletions Doc/library/contextlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,15 @@ Functions and classes provided:

This context manager is :ref:`reentrant <reentrant-cms>`.

If the code within the :keyword:`!with` block raises an
:exc:`ExceptionGroup`, suppressed exceptions are removed from the
group. If any exceptions in the group are not suppressed, a group containing them is re-raised.

.. versionadded:: 3.4

.. versionchanged:: 3.12
``suppress`` now supports suppressing exceptions raised as
part of an :exc:`ExceptionGroup`.

.. function:: redirect_stdout(new_target)

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/copyreg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Such constructors may be factory functions or class instances.
.. function:: pickle(type, function, constructor_ob=None)

Declares that *function* should be used as a "reduction" function for objects
of type *type*. *function* should return either a string or a tuple
containing two or three elements. See the :attr:`~pickle.Pickler.dispatch_table`
of type *type*. *function* must return either a string or a tuple
containing two or five elements. See the :attr:`~pickle.Pickler.dispatch_table`
for more details on the interface of *function*.

The *constructor_ob* parameter is a legacy feature and is now ignored, but if
Expand Down
Loading

0 comments on commit d82e315

Please sign in to comment.