Skip to content

Commit 6406871

Browse files
committed
Merge branch 'main' into specialize-iteration-with-jit
2 parents a55ac63 + 1f6a09f commit 6406871

Some content is hidden

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

52 files changed

+11651
-1345
lines changed

Doc/deprecations/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Deprecations
1515

1616
.. include:: pending-removal-in-future.rst
1717

18+
.. include:: soft-deprecations.rst
19+
1820
C API deprecations
1921
------------------
2022

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Soft deprecations
2+
-----------------
3+
4+
There are no plans to remove :term:`soft deprecated` APIs.
5+
6+
* :func:`re.match` and :meth:`re.Pattern.match` are now
7+
:term:`soft deprecated` in favor of the new :func:`re.prefixmatch` and
8+
:meth:`re.Pattern.prefixmatch` APIs, which have been added as alternate,
9+
more explicit names. These are intended to be used to alleviate confusion
10+
around what *match* means by following the Zen of Python's *"Explicit is
11+
better than implicit"* mantra. Most other language regular expression
12+
libraries use an API named *match* to mean what Python has always called
13+
*search*.
14+
15+
We **do not** plan to remove the older :func:`!match` name, as it has been
16+
used in code for over 30 years. Code supporting older versions of Python
17+
should continue to use :func:`!match`, while new code should prefer
18+
:func:`!prefixmatch`. See :ref:`prefixmatch-vs-match`.
19+
20+
(Contributed by Gregory P. Smith in :gh:`86519` and
21+
Hugo van Kemenade in :gh:`148100`.)

Doc/library/enum.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ Data types
502502
Using :class:`auto` with :class:`Enum` results in integers of increasing value,
503503
starting with ``1``.
504504

505-
.. versionchanged:: 3.12 Added :ref:`enum-dataclass-support`
505+
.. versionchanged:: 3.12 Added :ref:`enum-dataclass-support`.
506506

507507
.. method:: Enum._add_alias_
508508

@@ -977,9 +977,9 @@ Utilities and decorators
977977

978978
*auto* can be used in place of a value. If used, the *Enum* machinery will
979979
call an :class:`Enum`'s :meth:`~Enum._generate_next_value_` to get an appropriate value.
980-
For :class:`Enum` and :class:`IntEnum` that appropriate value will be the last value plus
981-
one; for :class:`Flag` and :class:`IntFlag` it will be the first power-of-two greater
982-
than the highest value; for :class:`StrEnum` it will be the lower-cased version of
980+
For :class:`Enum` and :class:`IntEnum` that appropriate value will be the highest value seen
981+
plus one; for :class:`Flag` and :class:`IntFlag` it will be the first power-of-two greater
982+
than the highest value seen; for :class:`StrEnum` it will be the lower-cased version of
983983
the member's name. Care must be taken if mixing *auto()* with manually
984984
specified values.
985985

@@ -989,8 +989,8 @@ Utilities and decorators
989989
* ``FIRST = auto()`` will work (auto() is replaced with ``1``);
990990
* ``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` is
991991
used to create the ``SECOND`` enum member;
992-
* ``THREE = [auto(), -3]`` will *not* work (``[<auto instance>, -3]`` is used to
993-
create the ``THREE`` enum member)
992+
* ``THIRD = [auto(), -3]`` will *not* work (``[<auto instance>, -3]`` is used to
993+
create the ``THIRD`` enum member)
994994

995995
.. versionchanged:: 3.11.1
996996

@@ -1000,7 +1000,7 @@ Utilities and decorators
10001000
``_generate_next_value_`` can be overridden to customize the values used by
10011001
*auto*.
10021002

1003-
.. note:: in 3.13 the default ``_generate_next_value_`` will always return
1003+
.. note:: In version 3.13 the default ``_generate_next_value_`` will always return
10041004
the highest member value incremented by 1, and will fail if any
10051005
member is an incompatible type.
10061006

@@ -1010,7 +1010,7 @@ Utilities and decorators
10101010
enumerations. It allows member attributes to have the same names as members
10111011
themselves.
10121012

1013-
.. note:: the *property* and the member must be defined in separate classes;
1013+
.. note:: The *property* and the member must be defined in separate classes;
10141014
for example, the *value* and *name* attributes are defined in the
10151015
*Enum* class, and *Enum* subclasses can define members with the
10161016
names ``value`` and ``name``.

Doc/library/http.server.rst

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ instantiation, of which this module provides three different variants:
9999

100100
This class is used to handle the HTTP requests that arrive at the server. By
101101
itself, it cannot respond to any actual HTTP requests; it must be subclassed
102-
to handle each request method (e.g. GET or POST).
102+
to handle each request method (for example, ``'GET'`` or ``'POST'``).
103103
:class:`BaseHTTPRequestHandler` provides a number of class and instance
104104
variables, and methods for use by subclasses.
105105

@@ -241,7 +241,7 @@ instantiation, of which this module provides three different variants:
241241
request header it responds back with a ``100 Continue`` followed by ``200
242242
OK`` headers.
243243
This method can be overridden to raise an error if the server does not
244-
want the client to continue. For e.g. server can choose to send ``417
244+
want the client to continue. For example, the server can choose to send ``417
245245
Expectation Failed`` as a response header and ``return False``.
246246

247247
.. versionadded:: 3.2
@@ -469,7 +469,9 @@ Command-line interface
469469

470470
:mod:`!http.server` can also be invoked directly using the :option:`-m`
471471
switch of the interpreter. The following example illustrates how to serve
472-
files relative to the current directory::
472+
files relative to the current directory:
473+
474+
.. code-block:: bash
473475
474476
python -m http.server [OPTIONS] [port]
475477
@@ -480,7 +482,9 @@ The following options are accepted:
480482
.. option:: port
481483

482484
The server listens to port 8000 by default. The default can be overridden
483-
by passing the desired port number as an argument::
485+
by passing the desired port number as an argument:
486+
487+
.. code-block:: bash
484488
485489
python -m http.server 9000
486490
@@ -489,7 +493,9 @@ The following options are accepted:
489493
Specifies a specific address to which it should bind. Both IPv4 and IPv6
490494
addresses are supported. By default, the server binds itself to all
491495
interfaces. For example, the following command causes the server to bind
492-
to localhost only::
496+
to localhost only:
497+
498+
.. code-block:: bash
493499
494500
python -m http.server --bind 127.0.0.1
495501
@@ -502,7 +508,9 @@ The following options are accepted:
502508

503509
Specifies a directory to which it should serve the files. By default,
504510
the server uses the current directory. For example, the following command
505-
uses a specific directory::
511+
uses a specific directory:
512+
513+
.. code-block:: bash
506514
507515
python -m http.server --directory /tmp/
508516
@@ -512,15 +520,19 @@ The following options are accepted:
512520

513521
Specifies the HTTP version to which the server is conformant. By default,
514522
the server is conformant to HTTP/1.0. For example, the following command
515-
runs an HTTP/1.1 conformant server::
523+
runs an HTTP/1.1 conformant server:
524+
525+
.. code-block:: bash
516526
517527
python -m http.server --protocol HTTP/1.1
518528
519529
.. versionadded:: 3.11
520530

521531
.. option:: --tls-cert
522532

523-
Specifies a TLS certificate chain for HTTPS connections::
533+
Specifies a TLS certificate chain for HTTPS connections:
534+
535+
.. code-block:: bash
524536
525537
python -m http.server --tls-cert fullchain.pem
526538
@@ -536,14 +548,16 @@ The following options are accepted:
536548

537549
.. option:: --tls-password-file
538550

539-
Specifies the password file for password-protected private keys::
551+
Specifies the password file for password-protected private keys:
552+
553+
.. code-block:: bash
540554
541555
python -m http.server \
542556
--tls-cert cert.pem \
543557
--tls-key key.pem \
544558
--tls-password-file password.txt
545559
546-
This option requires `--tls-cert`` to be specified.
560+
This option requires ``--tls-cert`` to be specified.
547561

548562
.. versionadded:: 3.14
549563

@@ -561,7 +575,7 @@ to be served.
561575

562576
Methods :meth:`BaseHTTPRequestHandler.send_header` and
563577
:meth:`BaseHTTPRequestHandler.send_response_only` assume sanitized input
564-
and does not perform input validation such as checking for the presence of CRLF
578+
and do not perform input validation such as checking for the presence of CRLF
565579
sequences. Untrusted input may result in HTTP Header injection attacks.
566580

567581
Earlier versions of Python did not scrub control characters from the

Doc/library/re.rst

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fine-tuning parameters.
5252

5353
.. _re-syntax:
5454

55-
Regular Expression Syntax
55+
Regular expression syntax
5656
-------------------------
5757

5858
A regular expression (or RE) specifies a set of strings that matches it; the
@@ -205,7 +205,7 @@ The special characters are:
205205
*without* establishing any backtracking points.
206206
This is the possessive version of the quantifier above.
207207
For example, on the 6-character string ``'aaaaaa'``, ``a{3,5}+aa``
208-
attempt to match 5 ``'a'`` characters, then, requiring 2 more ``'a'``\ s,
208+
attempts to match 5 ``'a'`` characters, then, requiring 2 more ``'a'``\ s,
209209
will need more characters than available and thus fail, while
210210
``a{3,5}aa`` will match with ``a{3,5}`` capturing 5, then 4 ``'a'``\ s
211211
by backtracking and then the final 2 ``'a'``\ s are matched by the final
@@ -717,7 +717,7 @@ three digits in length.
717717

718718
.. _contents-of-module-re:
719719

720-
Module Contents
720+
Module contents
721721
---------------
722722

723723
The module defines several functions, constants, and an exception. Some of the
@@ -833,8 +833,8 @@ Flags
833833
will be conditionally ORed with other flags. Example of use as a default
834834
value::
835835

836-
def myfunc(text, flag=re.NOFLAG):
837-
return re.search(text, flag)
836+
def myfunc(pattern, text, flag=re.NOFLAG):
837+
return re.search(pattern, text, flag)
838838

839839
.. versionadded:: 3.11
840840

@@ -954,9 +954,10 @@ Functions
954954
:func:`~re.match`. Use that name when you need to retain compatibility with
955955
older Python versions.
956956

957-
.. versionchanged:: 3.15
958-
The alternate :func:`~re.prefixmatch` name of this API was added as a
959-
more explicitly descriptive name than :func:`~re.match`. Use it to better
957+
.. deprecated:: 3.15
958+
:func:`~re.match` has been :term:`soft deprecated` in favor of
959+
the alternate :func:`~re.prefixmatch` name of this API which is
960+
more explicitly descriptive. Use it to better
960961
express intent. The norm in other languages and regular expression
961962
implementations is to use the term *match* to refer to the behavior of
962963
what Python has always called :func:`~re.search`.
@@ -1246,7 +1247,7 @@ Exceptions
12461247

12471248
.. _re-objects:
12481249

1249-
Regular Expression Objects
1250+
Regular expression objects
12501251
--------------------------
12511252

12521253
.. class:: Pattern
@@ -1309,9 +1310,10 @@ Regular Expression Objects
13091310
:meth:`~Pattern.match`. Use that name when you need to retain compatibility
13101311
with older Python versions.
13111312

1312-
.. versionchanged:: 3.15
1313-
The alternate :meth:`~Pattern.prefixmatch` name of this API was added as
1314-
a more explicitly descriptive name than :meth:`~Pattern.match`. Use it to
1313+
.. deprecated:: 3.15
1314+
:meth:`~Pattern.match` has been :term:`soft deprecated` in favor of
1315+
the alternate :meth:`~Pattern.prefixmatch` name of this API which is
1316+
more explicitly descriptive. Use it to
13151317
better express intent. The norm in other languages and regular expression
13161318
implementations is to use the term *match* to refer to the behavior of
13171319
what Python has always called :meth:`~Pattern.search`.
@@ -1396,7 +1398,7 @@ Regular Expression Objects
13961398

13971399
.. _match-objects:
13981400

1399-
Match Objects
1401+
Match objects
14001402
-------------
14011403

14021404
Match objects always have a boolean value of ``True``.
@@ -1615,11 +1617,11 @@ when there is no match, you can test whether there was a match with a simple
16151617

16161618
.. _re-examples:
16171619

1618-
Regular Expression Examples
1620+
Regular expression examples
16191621
---------------------------
16201622

16211623

1622-
Checking for a Pair
1624+
Checking for a pair
16231625
^^^^^^^^^^^^^^^^^^^
16241626

16251627
In this example, we'll use the following helper function to display match
@@ -1705,15 +1707,21 @@ expressions.
17051707
| ``%x``, ``%X`` | ``[-+]?(0[xX])?[\dA-Fa-f]+`` |
17061708
+--------------------------------+---------------------------------------------+
17071709

1708-
To extract the filename and numbers from a string like ::
1710+
To extract the filename and numbers from a string like:
1711+
1712+
.. code-block:: text
17091713
17101714
/usr/sbin/sendmail - 0 errors, 4 warnings
17111715
1712-
you would use a :c:func:`!scanf` format like ::
1716+
you would use a :c:func:`!scanf` format like:
1717+
1718+
.. code-block:: text
17131719
17141720
%s - %d errors, %d warnings
17151721
1716-
The equivalent regular expression would be ::
1722+
The equivalent regular expression would be:
1723+
1724+
.. code-block:: text
17171725
17181726
(\S+) - (\d+) errors, (\d+) warnings
17191727
@@ -1772,18 +1780,24 @@ not familiar with the Python API's divergence from what otherwise become the
17721780
industry norm.
17731781

17741782
Quoting from the Zen Of Python (``python3 -m this``): *"Explicit is better than
1775-
implicit"*. Anyone reading the name :func:`~re.prefixmatch` is likely to
1776-
understand the intended semantics. When reading :func:`~re.match` there remains
1783+
implicit"*. Anyone reading the name :func:`!prefixmatch` is likely to
1784+
understand the intended semantics. When reading :func:`!match` there remains
17771785
a seed of doubt about the intended behavior to anyone not already familiar with
17781786
this old Python gotcha.
17791787

1780-
We **do not** plan to deprecate and remove the older *match* name,
1788+
We **do not** plan to remove the older :func:`!match` name,
17811789
as it has been used in code for over 30 years.
1782-
Code supporting older versions of Python should continue to use *match*.
1790+
It has been :term:`soft deprecated`:
1791+
code supporting older versions of Python should continue to use :func:`!match`,
1792+
while new code should prefer :func:`!prefixmatch`.
17831793

17841794
.. versionadded:: 3.15
1795+
:func:`!prefixmatch`
1796+
1797+
.. deprecated:: 3.15
1798+
:func:`!match` is :term:`soft deprecated`
17851799

1786-
Making a Phonebook
1800+
Making a phonebook
17871801
^^^^^^^^^^^^^^^^^^
17881802

17891803
:func:`split` splits a string into a list delimited by the passed pattern. The
@@ -1844,7 +1858,7 @@ house number from the street name:
18441858
['Heather', 'Albrecht', '548.326.4584', '919', 'Park Place']]
18451859

18461860

1847-
Text Munging
1861+
Text munging
18481862
^^^^^^^^^^^^
18491863

18501864
:func:`sub` replaces every occurrence of a pattern with a string or the
@@ -1864,7 +1878,7 @@ in each word of a sentence except for the first and last characters::
18641878
'Pofsroser Aodlambelk, plasee reoprt yuor asnebces potlmrpy.'
18651879

18661880

1867-
Finding all Adverbs
1881+
Finding all adverbs
18681882
^^^^^^^^^^^^^^^^^^^
18691883

18701884
:func:`findall` matches *all* occurrences of a pattern, not just the first
@@ -1877,7 +1891,7 @@ the following manner::
18771891
['carefully', 'quickly']
18781892

18791893

1880-
Finding all Adverbs and their Positions
1894+
Finding all adverbs and their positions
18811895
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18821896

18831897
If one wants more information about all matches of a pattern than the matched
@@ -1893,7 +1907,7 @@ to find all of the adverbs *and their positions* in some text, they would use
18931907
40-47: quickly
18941908

18951909

1896-
Raw String Notation
1910+
Raw string notation
18971911
^^^^^^^^^^^^^^^^^^^
18981912

18991913
Raw string notation (``r"text"``) keeps regular expressions sane. Without it,
@@ -1917,7 +1931,7 @@ functionally identical::
19171931
<re.Match object; span=(0, 1), match='\\'>
19181932

19191933

1920-
Writing a Tokenizer
1934+
Writing a tokenizer
19211935
^^^^^^^^^^^^^^^^^^^
19221936

19231937
A `tokenizer or scanner <https://en.wikipedia.org/wiki/Lexical_analysis>`_

0 commit comments

Comments
 (0)