Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-72904-fnmatch-seps
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Sep 30, 2023
2 parents c70afe3 + 89966a6 commit 9cb2952
Show file tree
Hide file tree
Showing 162 changed files with 4,196 additions and 2,596 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ jobs:
run: make regen-configure
- name: Build CPython
run: |
# Deepfreeze will usually cause global objects to be added or removed,
# so we run it before regen-global-objects gets rum (in regen-all).
make regen-deepfreeze
make -j4 regen-all
make regen-stdlib-module-names
- name: Check for changes
Expand Down Expand Up @@ -261,7 +258,7 @@ jobs:
needs: check_source
if: needs.check_source.outputs.run_tests == 'true'
env:
OPENSSL_VER: 1.1.1v
OPENSSL_VER: 3.0.11
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -330,7 +327,7 @@ jobs:
strategy:
fail-fast: false
matrix:
openssl_ver: [1.1.1v, 3.0.10, 3.1.2]
openssl_ver: [1.1.1w, 3.0.11, 3.1.3]
env:
OPENSSL_VER: ${{ matrix.openssl_ver }}
MULTISSL_DIR: ${{ github.workspace }}/multissl
Expand Down Expand Up @@ -382,7 +379,7 @@ jobs:
needs: check_source
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
env:
OPENSSL_VER: 1.1.1v
OPENSSL_VER: 3.0.11
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -491,7 +488,7 @@ jobs:
needs: check_source
if: needs.check_source.outputs.run_tests == 'true'
env:
OPENSSL_VER: 1.1.1v
OPENSSL_VER: 3.0.11
PYTHONSTRICTEXTENSIONBUILD: 1
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
steps:
Expand Down
16 changes: 8 additions & 8 deletions Doc/howto/urllib2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ which comes after we have a look at what happens when things go wrong.
Handling Exceptions
===================

*urlopen* raises :exc:`URLError` when it cannot handle a response (though as
*urlopen* raises :exc:`~urllib.error.URLError` when it cannot handle a response (though as
usual with Python APIs, built-in exceptions such as :exc:`ValueError`,
:exc:`TypeError` etc. may also be raised).

:exc:`HTTPError` is the subclass of :exc:`URLError` raised in the specific case of
:exc:`~urllib.error.HTTPError` is the subclass of :exc:`~urllib.error.URLError` raised in the specific case of
HTTP URLs.

The exception classes are exported from the :mod:`urllib.error` module.
Expand Down Expand Up @@ -229,12 +229,12 @@ the status code indicates that the server is unable to fulfil the request. The
default handlers will handle some of these responses for you (for example, if
the response is a "redirection" that requests the client fetch the document from
a different URL, urllib will handle that for you). For those it can't handle,
urlopen will raise an :exc:`HTTPError`. Typical errors include '404' (page not
urlopen will raise an :exc:`~urllib.error.HTTPError`. Typical errors include '404' (page not
found), '403' (request forbidden), and '401' (authentication required).

See section 10 of :rfc:`2616` for a reference on all the HTTP error codes.

The :exc:`HTTPError` instance raised will have an integer 'code' attribute, which
The :exc:`~urllib.error.HTTPError` instance raised will have an integer 'code' attribute, which
corresponds to the error sent by the server.

Error Codes
Expand Down Expand Up @@ -317,7 +317,7 @@ dictionary is reproduced here for convenience ::
}

When an error is raised the server responds by returning an HTTP error code
*and* an error page. You can use the :exc:`HTTPError` instance as a response on the
*and* an error page. You can use the :exc:`~urllib.error.HTTPError` instance as a response on the
page returned. This means that as well as the code attribute, it also has read,
geturl, and info, methods as returned by the ``urllib.response`` module::

Expand All @@ -338,7 +338,7 @@ geturl, and info, methods as returned by the ``urllib.response`` module::
Wrapping it Up
--------------

So if you want to be prepared for :exc:`HTTPError` *or* :exc:`URLError` there are two
So if you want to be prepared for :exc:`~urllib.error.HTTPError` *or* :exc:`~urllib.error.URLError` there are two
basic approaches. I prefer the second approach.

Number 1
Expand All @@ -365,7 +365,7 @@ Number 1
.. note::

The ``except HTTPError`` *must* come first, otherwise ``except URLError``
will *also* catch an :exc:`HTTPError`.
will *also* catch an :exc:`~urllib.error.HTTPError`.

Number 2
~~~~~~~~
Expand All @@ -391,7 +391,7 @@ Number 2
info and geturl
===============

The response returned by urlopen (or the :exc:`HTTPError` instance) has two
The response returned by urlopen (or the :exc:`~urllib.error.HTTPError` instance) has two
useful methods :meth:`info` and :meth:`geturl` and is defined in the module
:mod:`urllib.response`..

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/asyncio-stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ and work with streams:
.. versionchanged:: 3.10
Removed the *loop* parameter.

.. versionchanged:: 3.11
Added the *ssl_shutdown_timeout* parameter.
.. versionchanged:: 3.11
Added the *ssl_shutdown_timeout* parameter.


.. coroutinefunction:: start_unix_server(client_connected_cb, path=None, \
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/codecs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ encodings.
+--------------------+---------+---------------------------+
| raw_unicode_escape | | Latin-1 encoding with |
| | | :samp:`\\u{XXXX}` and |
| | | :samp:`\\U{XXXXXXXX}`` |
| | | :samp:`\\U{XXXXXXXX}` |
| | | for other code points. |
| | | Existing |
| | | backslashes are not |
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ Common patterns for working with :class:`Counter` objects::
list(c) # list unique elements
set(c) # convert to a set
dict(c) # convert to a regular dictionary
c.items() # convert to a list of (elem, cnt) pairs
c.items() # access the (elem, cnt) pairs
Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs
c.most_common()[:-n-1:-1] # n least common elements
+c # remove zero and negative counts
Expand Down
38 changes: 25 additions & 13 deletions Doc/library/copy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,40 @@ pickle functions from the :mod:`copyreg` module.
single: __copy__() (copy protocol)
single: __deepcopy__() (copy protocol)

.. currentmodule:: None

In order for a class to define its own copy implementation, it can define
special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called
to implement the shallow copy operation; no additional arguments are passed.
The latter is called to implement the deep copy operation; it is passed one
argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
to make a deep copy of a component, it should call the :func:`deepcopy` function
with the component as first argument and the memo dictionary as second argument.
The memo dictionary should be treated as an opaque object.
special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`.

.. method:: object.__copy__(self)
:noindexentry:

Called to implement the shallow copy operation;
no additional arguments are passed.

.. method:: object.__deepcopy__(self, memo)
:noindexentry:

Called to implement the deep copy operation; it is passed one
argument, the *memo* dictionary. If the ``__deepcopy__`` implementation needs
to make a deep copy of a component, it should call the :func:`~copy.deepcopy` function
with the component as first argument and the *memo* dictionary as second argument.
The *memo* dictionary should be treated as an opaque object.


.. index::
single: __replace__() (replace protocol)

Function :func:`replace` is more limited than :func:`copy` and :func:`deepcopy`,
Function :func:`!copy.replace` is more limited
than :func:`~copy.copy` and :func:`~copy.deepcopy`,
and only supports named tuples created by :func:`~collections.namedtuple`,
:mod:`dataclasses`, and other classes which define method :meth:`!__replace__`.
:mod:`dataclasses`, and other classes which define method :meth:`~object.__replace__`.

.. method:: __replace__(self, /, **changes)
:noindex:
.. method:: object.__replace__(self, /, **changes)
:noindexentry:

:meth:`!__replace__` should create a new object of the same type,
replacing fields with values from *changes*.
This method should create a new object of the same type,
replacing fields with values from *changes*.


.. seealso::
Expand Down
5 changes: 3 additions & 2 deletions Doc/library/devmode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ Effects of the Python Development Mode:
``default``.

* Call :func:`faulthandler.enable` at Python startup to install handlers for
the :const:`SIGSEGV`, :const:`SIGFPE`, :const:`SIGABRT`, :const:`SIGBUS` and
:const:`SIGILL` signals to dump the Python traceback on a crash.
the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`,
:const:`~signal.SIGABRT`, :const:`~signal.SIGBUS` and
:const:`~signal.SIGILL` signals to dump the Python traceback on a crash.

It behaves as if the :option:`-X faulthandler <-X>` command line option is
used or if the :envvar:`PYTHONFAULTHANDLER` environment variable is set to
Expand Down
18 changes: 9 additions & 9 deletions Doc/library/difflib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ The :class:`SequenceMatcher` class has this constructor:

The three methods that return the ratio of matching to total characters can give
different results due to differing levels of approximation, although
:meth:`quick_ratio` and :meth:`real_quick_ratio` are always at least as large as
:meth:`ratio`:
:meth:`~SequenceMatcher.quick_ratio` and :meth:`~SequenceMatcher.real_quick_ratio`
are always at least as large as :meth:`~SequenceMatcher.ratio`:

>>> s = SequenceMatcher(None, "abcd", "bcde")
>>> s.ratio()
Expand All @@ -593,28 +593,28 @@ This example compares two strings, considering blanks to be "junk":
... "private Thread currentThread;",
... "private volatile Thread currentThread;")

:meth:`ratio` returns a float in [0, 1], measuring the similarity of the
sequences. As a rule of thumb, a :meth:`ratio` value over 0.6 means the
:meth:`~SequenceMatcher.ratio` returns a float in [0, 1], measuring the similarity of the
sequences. As a rule of thumb, a :meth:`~SequenceMatcher.ratio` value over 0.6 means the
sequences are close matches:

>>> print(round(s.ratio(), 3))
0.866

If you're only interested in where the sequences match,
:meth:`get_matching_blocks` is handy:
:meth:`~SequenceMatcher.get_matching_blocks` is handy:

>>> for block in s.get_matching_blocks():
... print("a[%d] and b[%d] match for %d elements" % block)
a[0] and b[0] match for 8 elements
a[8] and b[17] match for 21 elements
a[29] and b[38] match for 0 elements

Note that the last tuple returned by :meth:`get_matching_blocks` is always a
dummy, ``(len(a), len(b), 0)``, and this is the only case in which the last
Note that the last tuple returned by :meth:`~SequenceMatcher.get_matching_blocks`
is always a dummy, ``(len(a), len(b), 0)``, and this is the only case in which the last
tuple element (number of elements matched) is ``0``.

If you want to know how to change the first sequence into the second, use
:meth:`get_opcodes`:
:meth:`~SequenceMatcher.get_opcodes`:

>>> for opcode in s.get_opcodes():
... print("%6s a[%d:%d] b[%d:%d]" % opcode)
Expand Down Expand Up @@ -689,7 +689,7 @@ Differ Example

This example compares two texts. First we set up the texts, sequences of
individual single-line strings ending with newlines (such sequences can also be
obtained from the :meth:`~io.BaseIO.readlines` method of file-like objects):
obtained from the :meth:`~io.IOBase.readlines` method of file-like objects):

>>> text1 = ''' 1. Beautiful is better than ugly.
... 2. Explicit is better than implicit.
Expand Down
Loading

0 comments on commit 9cb2952

Please sign in to comment.