8000 Merge remote-tracking branch 'upstream/main' into default-to-30-bit-p… · python/cpython@8a761bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a761bf

Browse files
committed
Merge remote-tracking branch 'upstream/main' into default-to-30-bit-pylong-digits
2 parents 515c0e8 + f779fac commit 8a761bf

File tree

101 files changed

+2334
-1343
lines changed

Some content is hidden

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

101 files changed

+2334
-1343
lines changed

Doc/c-api/unicode.rst

Lines changed: 17 additions & 17 deletions
Return ``1`` or ``0`` depending on whether *ch* is a linebreak character.
Original file line numberDiff line numberDiff line change
@@ -268,57 +268,57 @@ are available through these macros which are mapped to C functions depending on
268268
the Python configuration.
269269
270270
271-
.. c:function:: int Py_UNICODE_ISSPACE(Py_UNICODE ch)
271+
.. c:function:: int Py_UNICODE_ISSPACE(Py_UCS4 ch)
272272
273273
Return ``1`` or ``0`` depending on whether *ch* is a whitespace character.
274274
275275
276-
.. c:function:: int Py_UNICODE_ISLOWER(Py_UNICODE ch)
276+
.. c:function:: int Py_UNICODE_ISLOWER(Py_UCS4 ch)
277277
278278
Return ``1`` or ``0`` depending on whether *ch* is a lowercase character.
279279
280280
281-
.. c:function:: int Py_UNICODE_ISUPPER(Py_UNICODE ch)
281+
.. c:function:: int Py_UNICODE_ISUPPER(Py_UCS4 ch)
282282
283283
Return ``1`` or ``0`` depending on whether *ch* is an uppercase character.
284284
285285
286-
.. c:function:: int Py_UNICODE_ISTITLE(Py_UNICODE ch)
286+
.. c:function:: int Py_UNICODE_ISTITLE(Py_UCS4 ch)
287287
288288
Return ``1`` or ``0`` depending on whether *ch* is a titlecase character.
289289
290290
291-
.. c:function:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch)
291+
.. c:function:: int Py_UNICODE_ISLINEBREAK(Py_UCS4 ch)
292292
293293
294294
295295
296-
.. c:function:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch)
296+
.. c:function:: int Py_UNICODE_ISDECIMAL(Py_UCS4 ch)
297297
298298
Return ``1`` or ``0`` depending on whether *ch* is a decimal character.
299299
300300
301-
.. c:function:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch)
301+
.. c:function:: int Py_UNICODE_ISDIGIT(Py_UCS4 ch)
302302
303303
Return ``1`` or ``0`` depending on whether *ch* is a digit character.
304304
305305
306-
.. c:function:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch)
306+
.. c:function:: int Py_UNICODE_ISNUMERIC(Py_UCS4 ch)
307307
308308
Return ``1`` or ``0`` depending on whether *ch* is a numeric character.
309309
310310
311-
.. c:function:: int Py_UNICODE_ISALPHA(Py_UNICODE ch)
311+
.. c:function:: int Py_UNICODE_ISALPHA(Py_UCS4 ch)
312312
313313
Return ``1`` or ``0`` depending on whether *ch* is an alphabetic character.
314314
315315
316-
.. c:function:: int Py_UNICODE_ISALNUM(Py_UNICODE ch)
316+
.. c:function:: int Py_UNICODE_ISALNUM(Py_UCS4 ch)
317317
318318
Return ``1`` or ``0`` depending on whether *ch* is an alphanumeric character.
319319
320320
321-
.. c:function:: int Py_UNICODE_ISPRINTABLE(Py_UNICODE ch)
321+
.. c:function:: int Py_UNICODE_ISPRINTABLE(Py_UCS4 ch)
322322
323323
Return ``1`` or ``0`` depending on whether *ch* is a printable character.
324324
Nonprintable characters are those characters defined in the Unicode character
@@ -332,43 +332,43 @@ the Python configuration.
332332
These APIs can be used for fast direct character conversions:
333333
334334
335-
.. c:function:: Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch)
335+
.. c:function:: Py_UCS4 Py_UNICODE_TOLOWER(Py_UCS4 ch)
336336
337337
Return the character *ch* converted to lower case.
338338
339339
.. deprecated:: 3.3
340340
This function uses simple case mappings.
341341
342342
343-
.. c:function:: Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch)
343+
.. c:function:: Py_UCS4 Py_UNICODE_TOUPPER(Py_UCS4 ch)
344344
345345
Return the character *ch* converted to upper case.
346346
347347
.. deprecated:: 3.3
348348
This function uses simple case mappings.
349349
350350
351-
.. c:function:: Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch)
351+
.. c:function:: Py_UCS4 Py_UNICODE_TOTITLE(Py_UCS4 ch)
352352
353353
Return the character *ch* converted to title case.
354354
355355
.. deprecated:: 3.3
356356
This function uses simple case mappings.
357357
358358
359-
.. c:function:: int Py_UNICODE_TODECIMAL(Py_UNICODE ch)
359+
.. c:function:: int Py_UNICODE_TODECIMAL(Py_UCS4 ch)
360360
361361
Return the character *ch* converted to a decimal positive integer. Return
362362
``-1`` if this is not possible. This macro does not raise exceptions.
363363
364364
365-
.. c:function:: int Py_UNICODE_TODIGIT(Py_UNICODE ch)
365+
.. c:function:: int Py_UNICODE_TODIGIT(Py_UCS4 ch)
366366
367367
Return the character *ch* converted to a single digit integer. Return ``-1`` if
368368
this is not possible. This macro does not raise exceptions.
369369
370370
371-
.. c:function:: double Py_UNICODE_TONUMERIC(Py_UNICODE ch)
371+
.. c:function:: double Py_UNICODE_TONUMERIC(Py_UCS4 ch)
372372
373373
Return the character *ch* converted to a double. Return ``-1.0`` if this is not
374374
possible. This macro does not raise exceptions.

Doc/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
html_theme_path = ['tools']
7070
html_theme_options = {
7171
'collapsiblesidebar': True,
72-
'issues_url': 'https://docs.python.org/3/bugs.html',
72+
'issues_url': '/bugs.html',
73+
'license_url': '/license.html',
7374
'root_include_title': False # We use the version switcher instead.
7475
}
7576

Doc/howto/enum.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -819,17 +819,20 @@ Some rules:
819819
1. When subclassing :class:`Enum`, mix-in types must appear before
820820
:class:`Enum` itself in the sequence of bases, as in the :class:`IntEnum`
821821
example above.
822-
2. While :class:`Enum` can have members of any type, once you mix in an
822+
2. Mix-in types must be subclassable. For example,
823+
:class:`bool` and :class:`range` are not subclassable
824+
and will throw an error during Enum creation if used as the mix-in type.
825+
3. While :class:`Enum` can have members of any type, once you mix in an
823826
additional type, all the members must have values of that type, e.g.
824827
:class:`int` above. This restriction does not apply to mix-ins which only
825828
add methods and don't specify another type.
826-
3. When another data type is mixed in, the :attr:`value` attribute is *not the
829+
4. When another data type is mixed in, the :attr:`value` attribute is *not the
827830
same* as the enum member itself, although it is equivalent and will compare
828831
equal.
829-
4. %-style formatting: `%s` and `%r` call the :class:`Enum` class's
832+
5. %-style formatting: `%s` and `%r` call the :class:`Enum` class's
830833
:meth:`__str__` and :meth:`__repr__` respectively; other codes (such as
831834
`%i` or `%h` for IntEnum) treat the enum member as its mixed-in type.
832-
5. :ref:`Formatted string literals <f-strings>`, :meth:`str.format`,
835+
6. :ref:`Formatted string literals <f-strings>`, :meth:`str.format`,
833836
and :func:`format` will use the mixed-in type's :meth:`__format__`
834837
unless :meth:`__str__` or :meth:`__format__` is overridden in the subclass,
835838
in which case the overridden methods or :class:`Enum` methods will be used.

Doc/library/hashlib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ More condensed:
120120

121121
Using :func:`new` with an algorithm provided by OpenSSL:
122122

123-
>>> h = hashlib.new('sha512_256')
123+
>>> h = hashlib.new('sha256')
124124
>>> h.update(b"Nobody inspects the spammish repetition")
125125
>>> h.hexdigest()
126-
'19197dc4d03829df858011c6c87600f994a858103bbc19005f20987aa19a97e2'
126+
'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'
127127

128128
Hashlib provides the following constant attributes:
129129

Doc/library/string.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,22 @@ these rules. The methods of :class:`Template` are:
783783
templates containing dangling delimiters, unmatched braces, or
784784
placeholders that are not valid Python identifiers.
785785

786+
787+
.. method:: is_valid()
788+
789+
Returns false if the template has invalid placeholders that will cause
790+
:meth:`substitute` to raise :exc:`ValueError`.
791+
792+
.. versionadded:: 3.11
793+
794+
795+
.. method:: get_identifiers()
796+
797+
Returns a list of the valid identifiers in the template, in the order
798+
they first appear, ignoring any invalid identifiers.
799+
800+
.. versionadded:: 3.11
801+
786802
:class:`Template` instances also provide one public data attribute:
787803

788804
.. attribute:: template
@@ -869,6 +885,9 @@ rule:
869885
* *invalid* -- This group matches any other delimiter pattern (usually a single
870886
delimiter), and it should appear last in the regular expression.
871887

888+
The methods on this class will raise :exc:`ValueError` if the pattern matches
889+
the template without one of these named groups matching.
890+
872891

873892
Helper functions
874893
----------------

Doc/library/sys.rst

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -378,26 +378,41 @@ always available.
378378
.. versionadded:: 3.8
379379
__unraisablehook__
380380

381+
382+
.. function:: exception()
383+
384+
This function returns the exception instance that is currently being
385+
handled. This exception is specific both to the current thread and
386+
to the current stack frame. If the current stack frame is not handling
387+
an exception, the exception is taken from the calling stack frame, or its
388+
caller, and so on until a stack frame is found that is handling an
389+
exception. Here, "handling an exception" is defined as "executing an
390+
except clause." For any stack frame, only the exception being currently
391+
handled is accessible.
392+
393+
.. index:: object: traceback
394+
395+
If no exception is being handled anywhere on the stack, ``None`` is
396+
returned.
397+
398+
.. versionadded:: 3.11
399+
400+
381401
.. function:: exc_info()
382402

383-
This function returns a tuple of three values that give information about the
384-
exception that is currently being handled. The information returned is specific
385-
both to the current thread and to the current stack frame. If the current stack
386-
frame is not handling an exception, the information is taken from the calling
387-
stack frame, or its caller, and so on until a stack frame is found that is
388-
handling an exception. Here, "handling an exception" is defined as "executing
389-
an except clause." For any stack frame, only information about the exception
390-
being currently handled is accessible.
403+
This function returns the old-style representation of the handled
404+
exception. If an exception ``e`` is currently handled (so
405+
:func:`exception` would return ``e``), :func:`exc_info` returns the
406+
tuple ``(type(e), e, e.__traceback__)``.
407+
That is, a tuple containing the type of the exception (a subclass of
408+
:exc:`BaseException`), the exception itself, and a :ref:`traceback
409+
object <traceback-objects>` which typically encapsulates the call
410+
stack at the point where the exception last occurred.
391411

392412
.. index:: object: traceback
393413

394-
If no exception is being handled anywhere on the stack, a tuple containing
395-
three ``None`` values is returned. Otherwise, the values returned are
396-
``(type, value, traceback)``. Their meaning is: *type* gets the type of the
397-
exception being handled (a subclass of :exc:`BaseException`); *value* gets
398-
the exception instance (an instance of the exception type); *traceback* gets
399-
a :ref:`traceback object <traceback-objects>` which typically encapsulates
400-
the call stack at the point where the exception last occurred.
414+
If no exception is being handled anywhere on the stack, this function
415+
return a tuple containing three ``None`` values.
401416

402417
.. versionchanged:: 3.11
403418
The ``type`` and ``traceback`` fields are now derived from the ``value``

Doc/library/typing.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ These can be used as types in annotations using ``[]``, each having a unique syn
737737

738738
from collections.abc import Callable
739739
from threading import Lock
740-
from typing import Any, Concatenate, ParamSpec, TypeVar
740+
from typing import Concatenate, ParamSpec, TypeVar
741741

742742
P = ParamSpec('P')
743743
R = TypeVar('R')
@@ -1985,6 +1985,15 @@ Functions and decorators
19851985

19861986
.. versionadded:: 3.8
19871987

1988+
.. versionchanged:: 3.11
1989+
The decorator will now set the ``__final__`` attribute to ``True``
1990+
on the decorated object. Thus, a check like
1991+
``if getattr(obj, "__final__", False)`` can be used at runtime
1992+
to determine whether an object ``obj`` has been marked as final.
1993+
If the decorated object does not support setting attributes,
1994+
the decorator returns the object unchanged without raising an exception.
1995+
1996+
19881997
.. decorator:: no_type_check
19891998

19901999
Decorator to indicate that annotations are not type hints.

Doc/library/unittest.rst

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ Test Discovery
266266

267267
Unittest supports simple test discovery. In order to be compatible with test
268268
discovery, all of the test files must be :ref:`modules <tut-modules>` or
269-
:ref:`packages <tut-packages>` (including :term:`namespace packages
270-
<namespace package>`) importable from the top-level directory of
269+
:ref:`packages <tut-packages>` importable from the top-level directory of
271270
the project (this means that their filenames must be valid :ref:`identifiers
272271
<identifiers>`).
273272

@@ -340,6 +339,24 @@ the `load_tests protocol`_.
340339
directory too (e.g.
341340
``python -m unittest discover -s root/namespace -t root``).
342341

342+
.. versionchanged:: 3.11
343+
Python 3.11 dropped the :term:`namespace packages <namespace package>`
344+
support. It has been broken since Python 3.7. Start directory and
345+
subdirectories containing tests must be regular package that have
346+
``__init__.py`` file.
347+
348+
Directories containing start directory still can be a namespace package.
349+
In this case, you need to specify start directory as dotted package name,
350+
and target directory explicitly. For example::
351+
352+
# proj/ <-- current directory
353+
# namespace/
354+
# mypkg/
355+
# __init__.py
356+
# test_mypkg.py
357+
358+
python -m unittest discover -s namespace.mypkg -t .
359+
343360

344361
.. _organizing-tests:
345362

@@ -1858,6 +1875,10 @@ Loading and running tests
18581875
whether their path matches *pattern*, because it is impossible for
18591876
a package name to match the default pattern.
18601877

1878+
.. versionchanged:: 3.11
1879+
*start_dir* can not be a :term:`namespace packages <namespace package>`.
1880+
It has been broken since Python 3.7 and Python 3.11 officially remove it.
1881+
18611882

18621883
The following attributes of a :class:`TestLoader` can be configured either by
18631884
subclassing or assignment on an instance:

Doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ blurb
99

1010
# The theme used by the documentation is stored separately, so we need
1111
# to install that as well.
12-
python-docs-theme
12+
python-docs-theme>=2022.1

Doc/tutorial/datastructures.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,12 @@ More on Conditions
659659
The conditions used in ``while`` and ``if`` statements can contain any
660660
operators, not just comparisons.
661661

662-
The comparison operators ``in`` and ``not in`` check whether a value occurs
663-
(does not occur) in a sequence. The operators ``is`` and ``is not`` compare
664-
whether two objects are really the same object. All comparison operators have
665-
the same priority, which is lower than that of all numerical operators.
662+
663+
The comparison operators ``in`` and ``not in`` are membership tests that
664+
determine whether a value is in (or not in) a container. The operators ``is``
665+
and ``is not`` compare whether two objects are really the same object. All
666+
comparison operators have the same priority, which is lower than that of all
667+
numerical operators.
666668

667669
Comparisons can be chained. For example, ``a < b == c`` tests whether ``a`` is
668670
less than ``b`` and moreover ``b`` equals ``c``.

0 commit comments

Comments
 (0)
0