Skip to content

Commit cbc9d60

Browse files
Merge branch 'main' into dict
2 parents 60c8434 + b44c824 commit cbc9d60

File tree

92 files changed

+1406
-822
lines changed

Some content is hidden

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

92 files changed

+1406
-822
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ repos:
4747
exclude: Lib/test/tokenizedata/coding20731.py
4848
- id: trailing-whitespace
4949
types_or: [c, inc, python, rst]
50+
- id: trailing-whitespace
51+
files: '\.(gram)$'
5052

5153
- repo: https://github.com/python-jsonschema/check-jsonschema
5254
rev: 0.33.0

Doc/library/fcntl.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ The module defines the following functions:
107107
passed to the C :c:func:`fcntl` call. The return value after a successful
108108
call is the contents of the buffer, converted to a :class:`bytes` object.
109109
The length of the returned object will be the same as the length of the
110-
*arg* argument. This is limited to 1024 bytes.
110+
*arg* argument.
111111

112112
If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised.
113113

114114
.. note::
115-
If the type or the size of *arg* does not match the type or size
116-
of the argument of the operation (for example, if an integer is
115+
If the type or size of *arg* does not match the type or size
116+
of the operation's argument (for example, if an integer is
117117
passed when a pointer is expected, or the information returned in
118-
the buffer by the operating system is larger than 1024 bytes),
118+
the buffer by the operating system is larger than the size of *arg*),
119119
this is most likely to result in a segmentation violation or
120120
a more subtle data corruption.
121121

@@ -125,6 +125,9 @@ The module defines the following functions:
125125
Add support of arbitrary :term:`bytes-like objects <bytes-like object>`,
126126
not only :class:`bytes`.
127127

128+
.. versionchanged:: next
129+
The size of bytes-like objects is no longer limited to 1024 bytes.
130+
128131

129132
.. function:: ioctl(fd, request, arg=0, mutate_flag=True, /)
130133

@@ -161,8 +164,7 @@ The module defines the following functions:
161164
If the type or size of *arg* does not match the type or size
162165
of the operation's argument (for example, if an integer is
163166
passed when a pointer is expected, or the information returned in
164-
the buffer by the operating system is larger than 1024 bytes,
165-
or the size of the mutable bytes-like object is too small),
167+
the buffer by the operating system is larger than the size of *arg*),
166168
this is most likely to result in a segmentation violation or
167169
a more subtle data corruption.
168170

@@ -185,6 +187,10 @@ The module defines the following functions:
185187
The GIL is always released during a system call.
186188
System calls failing with EINTR are automatically retried.
187189

190+
.. versionchanged:: next
191+
The size of not mutated bytes-like objects is no longer
192+
limited to 1024 bytes.
193+
188194
.. function:: flock(fd, operation, /)
189195

190196
Perform the lock operation *operation* on file descriptor *fd* (file objects providing

Doc/library/heapq.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ The strange invariant above is meant to be an efficient memory representation
315315
for a tournament. The numbers below are *k*, not ``a[k]``:
316316

317317
.. figure:: heapq-binary-tree.svg
318+
:class: invert-in-dark-mode
318319
:align: center
319320
:alt: Example (min-heap) binary tree.
320321

Doc/library/logging.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,8 +1342,9 @@ functions.
13421342

13431343
.. function:: basicConfig(**kwargs)
13441344

1345-
Does basic configuration for the logging system by creating a
1346-
:class:`StreamHandler` with a default :class:`Formatter` and adding it to the
1345+
Does basic configuration for the logging system by either creating a
1346+
:class:`StreamHandler` with a default :class:`Formatter`
1347+
or using the given *formatter* instance, and adding it to the
13471348
root logger. The functions :func:`debug`, :func:`info`, :func:`warning`,
13481349
:func:`error` and :func:`critical` will call :func:`basicConfig` automatically
13491350
if no handlers are defined for the root logger.
@@ -1428,6 +1429,19 @@ functions.
14281429
| | which means that it will be treated the |
14291430
| | same as passing 'errors'. |
14301431
+--------------+---------------------------------------------+
1432+
| *formatter* | If specified, set this formatter instance |
1433+
| | (see :ref:`formatter-objects`) |
1434+
| | for all involved handlers. |
1435+
| | If not specified, the default is to create |
1436+
| | and use an instance of |
1437+
| | :class:`logging.Formatter` based on |
1438+
| | arguments *format*, *datefmt* and *style*. |
1439+
| | When *formatter* is specified together with |
1440+
| | any of the three arguments *format*, |
1441+
| | *datefmt* and *style*, a ``ValueError`` is |
1442+
| | raised to signal that these arguments would |
1443+
| | lose meaning otherwise. |
1444+
+--------------+---------------------------------------------+
14311445

14321446
.. versionchanged:: 3.2
14331447
The *style* argument was added.
@@ -1444,6 +1458,9 @@ functions.
14441458
.. versionchanged:: 3.9
14451459
The *encoding* and *errors* arguments were added.
14461460

1461+
.. versionchanged:: 3.15
1462+
The *formatter* argument was added.
1463+
14471464
.. function:: shutdown()
14481465

14491466
Informs the logging system to perform an orderly shutdown by flushing and

Doc/library/math.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ Number-theoretic functions
144144

145145
.. function:: factorial(n)
146146

147-
Return *n* factorial as an integer. Raises :exc:`ValueError` if *n* is not integral or
148-
is negative.
147+
Return factorial of the nonnegative integer *n*.
149148

150149
.. versionchanged:: 3.10
151150
Floats with integral values (like ``5.0``) are no longer accepted.

Doc/library/stdtypes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,6 +2269,18 @@ expression support in the :mod:`re` module).
22692269
>>> ' 1 2 3 '.split()
22702270
['1', '2', '3']
22712271

2272+
If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only
2273+
leading runs of consecutive whitespace are considered.
2274+
2275+
For example::
2276+
2277+
>>> "".split(None, 0)
2278+
[]
2279+
>>> " ".split(None, 0)
2280+
[]
2281+
>>> " foo ".split(maxsplit=0)
2282+
['foo ']
2283+
22722284

22732285
.. index::
22742286
single: universal newlines; str.splitlines method

Doc/library/unittest.mock.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,9 +2654,9 @@ with any methods on the mock:
26542654

26552655
.. code-block:: pycon
26562656
2657-
>>> mock.has_data()
2657+
>>> mock.header_items()
26582658
<mock.Mock object at 0x...>
2659-
>>> mock.has_data.assret_called_with() # Intentional typo!
2659+
>>> mock.header_items.assret_called_with() # Intentional typo!
26602660
26612661
Auto-speccing solves this problem. You can either pass ``autospec=True`` to
26622662
:func:`patch` / :func:`patch.object` or use the :func:`create_autospec` function to create a

Doc/library/urllib.request.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ HTTPHandler Objects
11211121
.. method:: HTTPHandler.http_open(req)
11221122

11231123
Send an HTTP request, which can be either GET or POST, depending on
1124-
``req.has_data()``.
1124+
``req.data``.
11251125

11261126

11271127
.. _https-handler-objects:
@@ -1133,7 +1133,7 @@ HTTPSHandler Objects
11331133
.. method:: HTTPSHandler.https_open(req)
11341134

11351135
Send an HTTPS request, which can be either GET or POST, depending on
1136-
``req.has_data()``.
1136+
``req.data``.
11371137

11381138

11391139
.. _file-handler-objects:

Doc/using/windows.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,10 @@ To install the file downloaded from python.org, either double-click and select
7777
"Install", or run ``Add-AppxPackage <path to MSIX>`` in Windows Powershell.
7878

7979
After installation, the ``python``, ``py``, and ``pymanager`` commands should be
80-
available. If they are not, click Start and search for "Manage app execution
81-
aliases". This settings page will let you enable the relevant commands. They
82-
will be labelled "Python (default)", "Python (default windowed)", and "Python
83-
install manager".
84-
85-
If you have existing installations of Python, or you have modified your
86-
:envvar:`PATH` variable, you may need to remove them or undo the modifications
87-
in order for the commands to work. Old versions of Python can be reinstalled
88-
using the Python install manager.
80+
available. If you have existing installations of Python, or you have modified
81+
your :envvar:`PATH` variable, you may need to remove them or undo the
82+
modifications. See :ref:`pymanager-troubleshoot` for more help with fixing
83+
non-working commands.
8984

9085
When you first install a runtime, you will likely be prompted to add a directory
9186
to your :envvar:`PATH`. This is optional, if you prefer to use the ``py``
@@ -150,6 +145,10 @@ want to be passed to the runtime (such as script files or the module to launch):
150145
$> py -m this
151146
...
152147
148+
The default runtime can be overridden with the :envvar:`PYTHON_MANAGER_DEFAULT`
149+
environment variable, or a configuration file. See :ref:`pymanager-config` for
150+
information about configuration settings.
151+
153152
To launch a specific runtime, the ``py`` command accepts a ``-V:<TAG>`` option.
154153
This option must be specified before any others. The tag is part or all of the
155154
identifier for the runtime; for those from the CPython team, it looks like the
@@ -472,6 +471,10 @@ directory (which you may have added to your :envvar:`PATH` environment variable)
472471
can be used in a shebang, even if it is not on your :envvar:`PATH`. This allows
473472
the use of shebangs like ``/usr/bin/python3.12`` to select a particular runtime.
474473

474+
If no runtimes are installed, or if automatic installation is enabled, the
475+
requested runtime will be installed if necessary. See :ref:`pymanager-config`
476+
for information about configuration settings.
477+
475478
The ``/usr/bin/env`` form of shebang line will also search the :envvar:`PATH`
476479
environment variable for unrecognized commands. This corresponds to the
477480
behaviour of the Unix ``env`` program, which performs the same search, but

Grammar/python.gram

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ func_type[mod_ty]: '(' a=[type_expressions] ')' '->' b=expression NEWLINE* ENDMA
9696

9797
statements[asdl_stmt_seq*]: a=statement+ { _PyPegen_register_stmts(p, (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a)) }
9898

99-
statement[asdl_stmt_seq*]:
100-
| a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
99+
statement[asdl_stmt_seq*]:
100+
| a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
101101
| a[asdl_stmt_seq*]=simple_stmts { a }
102102

103103
single_compound_stmt[asdl_stmt_seq*]:
104-
| a=compound_stmt {
104+
| a=compound_stmt {
105105
_PyPegen_register_stmts(p, (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a)) }
106106

107107
statement_newline[asdl_stmt_seq*]:
@@ -449,9 +449,9 @@ except_block[excepthandler_ty]:
449449
_PyAST_ExceptHandler(e, ((expr_ty) t)->v.Name.id, b, EXTRA) }
450450
| 'except' e=expressions ':' b=block {
451451
CHECK_VERSION(
452-
excepthandler_ty,
453-
14,
454-
"except expressions without parentheses are",
452+
excepthandler_ty,
453+
14,
454+
"except expressions without parentheses are",
455455
_PyAST_ExceptHandler(e, NULL, b, EXTRA)) }
456456
| 'except' ':' b=block { _PyAST_ExceptHandler(NULL, NULL, b, EXTRA) }
457457
| invalid_except_stmt
@@ -463,9 +463,9 @@ except_star_block[excepthandler_ty]:
463463
_PyAST_ExceptHandler(e, ((expr_ty) t)->v.Name.id, b, EXTRA) }
464464
| 'except' '*' e=expressions ':' b=block {
465465
CHECK_VERSION(
466-
excepthandler_ty,
467-
14,
468-
"except expressions without parentheses are",
466+
excepthandler_ty,
467+
14,
468+
"except expressions without parentheses are",
469469
_PyAST_ExceptHandler(e, NULL, b, EXTRA)) }
470470
| invalid_except_star_stmt
471471
finally_block[asdl_stmt_seq*]:
@@ -977,11 +977,11 @@ tstring_middle[expr_ty]:
977977
| tstring_replacement_field
978978
| t=TSTRING_MIDDLE { _PyPegen_constant_from_token(p, t) }
979979
tstring[expr_ty] (memo):
980-
| a=TSTRING_START b=tstring_middle* c=TSTRING_END {
980+
| a=TSTRING_START b=tstring_middle* c=TSTRING_END {
981981
CHECK_VERSION(
982-
expr_ty,
983-
14,
984-
"t-strings are",
982+
expr_ty,
983+
14,
984+
"t-strings are",
985985
_PyPegen_template_str(p, a, (asdl_expr_seq*)b, c)) }
986986

987987
string[expr_ty]: s[Token*]=STRING { _PyPegen_constant_from_string(p, s) }
@@ -1383,11 +1383,11 @@ invalid_import:
13831383
RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }
13841384
invalid_dotted_as_name:
13851385
| dotted_name 'as' !(NAME (',' | ')' | NEWLINE)) a=expression {
1386-
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
1386+
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
13871387
"cannot use %s as import target", _PyPegen_get_expr_name(a)) }
13881388
invalid_import_from_as_name:
13891389
| NAME 'as' !(NAME (',' | ')' | NEWLINE)) a=expression {
1390-
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
1390+
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
13911391
"cannot use %s as import target", _PyPegen_get_expr_name(a)) }
13921392

13931393
invalid_import_from_targets:

0 commit comments

Comments
 (0)