Skip to content

Commit f1aa731

Browse files
authored
Merge branch 'main' into fix_typo_in_functional_howto
2 parents 3d2d7db + 5d118d0 commit f1aa731

26 files changed

+261
-92
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/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/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

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:

Include/internal/pycore_dict.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ extern int _PyDict_Pop_KnownHash(
150150
Py_hash_t hash,
151151
PyObject **result);
152152

153+
extern void _PyDict_Clear_LockHeld(PyObject *op);
154+
153155
#ifdef Py_GIL_DISABLED
154156
PyAPI_FUNC(void) _PyDict_EnsureSharedOnRead(PyDictObject *mp);
155157
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Lib/compression/zstd/__init__.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22

33
__all__ = (
44
# compression.zstd
5-
"COMPRESSION_LEVEL_DEFAULT",
6-
"compress",
7-
"CompressionParameter",
8-
"decompress",
9-
"DecompressionParameter",
10-
"finalize_dict",
11-
"get_frame_info",
12-
"Strategy",
13-
"train_dict",
5+
'COMPRESSION_LEVEL_DEFAULT',
6+
'compress',
7+
'CompressionParameter',
8+
'decompress',
9+
'DecompressionParameter',
10+
'finalize_dict',
11+
'get_frame_info',
12+
'Strategy',
13+
'train_dict',
1414

1515
# compression.zstd._zstdfile
16-
"open",
17-
"ZstdFile",
16+
'open',
17+
'ZstdFile',
1818

1919
# _zstd
20-
"get_frame_size",
21-
"zstd_version",
22-
"zstd_version_info",
23-
"ZstdCompressor",
24-
"ZstdDecompressor",
25-
"ZstdDict",
26-
"ZstdError",
20+
'get_frame_size',
21+
'zstd_version',
22+
'zstd_version_info',
23+
'ZstdCompressor',
24+
'ZstdDecompressor',
25+
'ZstdDict',
26+
'ZstdError',
2727
)
2828

2929
import _zstd
@@ -43,6 +43,7 @@
4343

4444
class FrameInfo:
4545
"""Information about a Zstandard frame."""
46+
4647
__slots__ = 'decompressed_size', 'dictionary_id'
4748

4849
def __init__(self, decompressed_size, dictionary_id):
@@ -125,13 +126,13 @@ def finalize_dict(zstd_dict, /, samples, dict_size, level):
125126
chunks = b''.join(samples)
126127
chunk_sizes = tuple(_nbytes(sample) for sample in samples)
127128
if not chunks:
128-
raise ValueError("The samples are empty content, can't finalize the"
129+
raise ValueError("The samples are empty content, can't finalize the "
129130
"dictionary.")
130-
dict_content = _zstd.finalize_dict(zstd_dict.dict_content,
131-
chunks, chunk_sizes,
132-
dict_size, level)
131+
dict_content = _zstd.finalize_dict(zstd_dict.dict_content, chunks,
132+
chunk_sizes, dict_size, level)
133133
return ZstdDict(dict_content)
134134

135+
135136
def compress(data, level=None, options=None, zstd_dict=None):
136137
"""Return Zstandard compressed *data* as bytes.
137138
@@ -147,6 +148,7 @@ def compress(data, level=None, options=None, zstd_dict=None):
147148
comp = ZstdCompressor(level=level, options=options, zstd_dict=zstd_dict)
148149
return comp.compress(data, mode=ZstdCompressor.FLUSH_FRAME)
149150

151+
150152
def decompress(data, zstd_dict=None, options=None):
151153
"""Decompress one or more frames of Zstandard compressed *data*.
152154
@@ -162,12 +164,12 @@ def decompress(data, zstd_dict=None, options=None):
162164
decomp = ZstdDecompressor(options=options, zstd_dict=zstd_dict)
163165
results.append(decomp.decompress(data))
164166
if not decomp.eof:
165-
raise ZstdError("Compressed data ended before the "
166-
"end-of-stream marker was reached")
167+
raise ZstdError('Compressed data ended before the '
168+
'end-of-stream marker was reached')
167169
data = decomp.unused_data
168170
if not data:
169171
break
170-
return b"".join(results)
172+
return b''.join(results)
171173

172174

173175
class CompressionParameter(enum.IntEnum):

0 commit comments

Comments
 (0)