Skip to content

Commit 1dcce83

Browse files
Merge branch 'main' into gh-148849-deprecate-js-output
2 parents b169fc8 + 1e7dfbc commit 1dcce83

57 files changed

Lines changed: 1285 additions & 578 deletions

Some content is hidden

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

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Pending removal in Python 3.15
6060

6161
* :mod:`types`:
6262

63-
* :class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was
63+
* :class:`types.CodeType`: Accessing :attr:`!codeobject.co_lnotab` was
6464
deprecated in :pep:`626`
6565
since 3.10 and was planned to be removed in 3.12,
6666
but it only got a proper :exc:`DeprecationWarning` in 3.12.

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ although there is currently no date scheduled for their removal.
4747

4848
* :mod:`codecs`: use :func:`open` instead of :func:`codecs.open`. (:gh:`133038`)
4949

50-
* :attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method
50+
* :attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method
5151
instead.
5252

5353
* :mod:`datetime`:

Doc/library/ast.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2480,7 +2480,7 @@ and classes for traversing abstract syntax trees:
24802480
node = YourTransformer().visit(node)
24812481

24822482

2483-
.. function:: dump(node, annotate_fields=True, include_attributes=False, *, indent=None, show_empty=False)
2483+
.. function:: dump(node, annotate_fields=True, include_attributes=False, *, color=False, indent=None, show_empty=False)
24842484

24852485
Return a formatted dump of the tree in *node*. This is mainly useful for
24862486
debugging purposes. If *annotate_fields* is true (by default),
@@ -2490,6 +2490,10 @@ and classes for traversing abstract syntax trees:
24902490
numbers and column offsets are not dumped by default. If this is wanted,
24912491
*include_attributes* can be set to true.
24922492

2493+
If *color* is ``True``, the returned string is syntax highlighted using
2494+
ANSI escape sequences.
2495+
If ``False`` (the default), colored output is always disabled.
2496+
24932497
If *indent* is a non-negative integer or string, then the tree will be
24942498
pretty-printed with that indent level. An indent level
24952499
of 0, negative, or ``""`` will only insert newlines. ``None`` (the default)
@@ -2527,6 +2531,9 @@ and classes for traversing abstract syntax trees:
25272531
.. versionchanged:: 3.15
25282532
Omit optional ``Load()`` values by default.
25292533

2534+
.. versionchanged:: next
2535+
Added the *color* parameter.
2536+
25302537

25312538
.. _ast-compiler-flags:
25322539

@@ -2584,6 +2591,10 @@ Command-line usage
25842591

25852592
.. versionadded:: 3.9
25862593

2594+
.. versionchanged:: next
2595+
The output is now syntax highlighted by default. This can be
2596+
:ref:`controlled using environment variables <using-on-controlling-color>`.
2597+
25872598
The :mod:`!ast` module can be executed as a script from the command line.
25882599
It is as simple as:
25892600

Doc/library/base64.rst

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ POST request.
7373
Added the *padded* and *wrapcol* parameters.
7474

7575

76-
.. function:: b64decode(s, altchars=None, validate=False, *, padded=True)
77-
b64decode(s, altchars=None, validate=True, *, ignorechars, padded=True)
76+
.. function:: b64decode(s, altchars=None, validate=False, *, padded=True, canonical=False)
77+
b64decode(s, altchars=None, validate=True, *, ignorechars, padded=True, canonical=False)
7878
7979
Decode the Base64 encoded :term:`bytes-like object` or ASCII string
8080
*s* and return the decoded :class:`bytes`.
@@ -112,10 +112,13 @@ POST request.
112112
If *validate* is true, these non-alphabet characters in the input
113113
result in a :exc:`binascii.Error`.
114114

115+
If *canonical* is true, non-zero padding bits are rejected.
116+
See :func:`binascii.a2b_base64` for details.
117+
115118
For more information about the strict base64 check, see :func:`binascii.a2b_base64`
116119

117120
.. versionchanged:: 3.15
118-
Added the *ignorechars* and *padded* parameters.
121+
Added the *canonical*, *ignorechars*, and *padded* parameters.
119122

120123
.. deprecated:: 3.15
121124
Accepting the ``+`` and ``/`` characters with an alternative alphabet
@@ -179,7 +182,7 @@ POST request.
179182
Added the *padded* and *wrapcol* parameters.
180183

181184

182-
.. function:: b32decode(s, casefold=False, map01=None, *, padded=True, ignorechars=b'')
185+
.. function:: b32decode(s, casefold=False, map01=None, *, padded=True, ignorechars=b'', canonical=False)
183186

184187
Decode the Base32 encoded :term:`bytes-like object` or ASCII string *s* and
185188
return the decoded :class:`bytes`.
@@ -205,12 +208,15 @@ POST request.
205208
*ignorechars* should be a :term:`bytes-like object` containing characters
206209
to ignore from the input.
207210

211+
If *canonical* is true, non-zero padding bits are rejected.
212+
See :func:`binascii.a2b_base32` for details.
213+
208214
A :exc:`binascii.Error` is raised if *s* is
209215
incorrectly padded or if there are non-alphabet characters present in the
210216
input.
211217

212218
.. versionchanged:: 3.15
213-
Added the *ignorechars* and *padded* parameters.
219+
Added the *canonical*, *ignorechars*, and *padded* parameters.
214220

215221

216222
.. function:: b32hexencode(s, *, padded=True, wrapcol=0)
@@ -224,7 +230,7 @@ POST request.
224230
Added the *padded* and *wrapcol* parameters.
225231

226232

227-
.. function:: b32hexdecode(s, casefold=False, *, padded=True, ignorechars=b'')
233+
.. function:: b32hexdecode(s, casefold=False, *, padded=True, ignorechars=b'', canonical=False)
228234

229235
Similar to :func:`b32decode` but uses the Extended Hex Alphabet, as defined in
230236
:rfc:`4648`.
@@ -237,7 +243,7 @@ POST request.
237243
.. versionadded:: 3.10
238244

239245
.. versionchanged:: 3.15
240-
Added the *ignorechars* and *padded* parameters.
246+
Added the *canonical*, *ignorechars*, and *padded* parameters.
241247

242248

243249
.. function:: b16encode(s, *, wrapcol=0)
@@ -317,7 +323,7 @@ Refer to the documentation of the individual functions for more information.
317323
.. versionadded:: 3.4
318324

319325

320-
.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v')
326+
.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v', canonical=False)
321327

322328
Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and
323329
return the decoded :class:`bytes`.
@@ -334,8 +340,16 @@ Refer to the documentation of the individual functions for more information.
334340
This should only contain whitespace characters, and by
335341
default contains all whitespace characters in ASCII.
336342

343+
If *canonical* is true, non-canonical encodings are rejected.
344+
See :func:`binascii.a2b_ascii85` for details.
345+
337346
.. versionadded:: 3.4
338347

348+
.. versionchanged:: next
349+
Added the *canonical* parameter.
350+
Single-character final groups are now always rejected as encoding
351+
violations.
352+
339353

340354
.. function:: b85encode(b, pad=False, *, wrapcol=0)
341355

@@ -355,7 +369,7 @@ Refer to the documentation of the individual functions for more information.
355369
Added the *wrapcol* parameter.
356370

357371

358-
.. function:: b85decode(b, *, ignorechars=b'')
372+
.. function:: b85decode(b, *, ignorechars=b'', canonical=False)
359373

360374
Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and
361375
return the decoded :class:`bytes`. Padding is implicitly removed, if
@@ -364,10 +378,15 @@ Refer to the documentation of the individual functions for more information.
364378
*ignorechars* should be a :term:`bytes-like object` containing characters
365379
to ignore from the input.
366380

381+
If *canonical* is true, non-canonical encodings are rejected.
382+
See :func:`binascii.a2b_base85` for details.
383+
367384
.. versionadded:: 3.4
368385

369386
.. versionchanged:: 3.15
370-
Added the *ignorechars* parameter.
387+
Added the *canonical* and *ignorechars* parameters.
388+
Single-character final groups are now always rejected as encoding
389+
violations.
371390

372391

373392
.. function:: z85encode(s, pad=False, *, wrapcol=0)
@@ -392,7 +411,7 @@ Refer to the documentation of the individual functions for more information.
392411
Added the *wrapcol* parameter.
393412

394413

395-
.. function:: z85decode(s, *, ignorechars=b'')
414+
.. function:: z85decode(s, *, ignorechars=b'', canonical=False)
396415

397416
Decode the Z85-encoded :term:`bytes-like object` or ASCII string *s* and
398417
return the decoded :class:`bytes`. See `Z85 specification
@@ -401,10 +420,15 @@ Refer to the documentation of the individual functions for more information.
401420
*ignorechars* should be a :term:`bytes-like object` containing characters
402421
to ignore from the input.
403422

423+
If *canonical* is true, non-canonical encodings are rejected.
424+
See :func:`binascii.a2b_base85` for details.
425+
404426
.. versionadded:: 3.13
405427

406428
.. versionchanged:: 3.15
407-
Added the *ignorechars* parameter.
429+
Added the *canonical* and *ignorechars* parameters.
430+
Single-character final groups are now always rejected as encoding
431+
violations.
408432

409433

410434
.. _base64-legacy:

Doc/library/binascii.rst

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ The :mod:`!binascii` module defines the following functions:
4848
Added the *backtick* parameter.
4949

5050

51-
.. function:: a2b_base64(string, /, *, padded=True, alphabet=BASE64_ALPHABET, strict_mode=False)
52-
a2b_base64(string, /, *, ignorechars, padded=True, alphabet=BASE64_ALPHABET, strict_mode=True)
51+
.. function:: a2b_base64(string, /, *, padded=True, alphabet=BASE64_ALPHABET, strict_mode=False, canonical=False)
52+
a2b_base64(string, /, *, ignorechars, padded=True, alphabet=BASE64_ALPHABET, strict_mode=True, canonical=False)
5353
5454
Convert a block of base64 data back to binary and return the binary data. More
5555
than one line may be passed at a time.
@@ -83,11 +83,15 @@ The :mod:`!binascii` module defines the following functions:
8383
* Contains no excess data after padding (including excess padding, newlines, etc.).
8484
* Does not start with a padding.
8585

86+
If *canonical* is true, non-zero padding bits in the last group are rejected
87+
with :exc:`binascii.Error`, enforcing canonical encoding as defined in
88+
:rfc:`4648` section 3.5. This check is independent of *strict_mode*.
89+
8690
.. versionchanged:: 3.11
8791
Added the *strict_mode* parameter.
8892

8993
.. versionchanged:: 3.15
90-
Added the *alphabet*, *ignorechars* and *padded* parameters.
94+
Added the *alphabet*, *canonical*, *ignorechars*, and *padded* parameters.
9195

9296

9397
.. function:: b2a_base64(data, *, padded=True, alphabet=BASE64_ALPHABET, wrapcol=0, newline=True)
@@ -113,7 +117,7 @@ The :mod:`!binascii` module defines the following functions:
113117
Added the *alphabet*, *padded* and *wrapcol* parameters.
114118

115119

116-
.. function:: a2b_ascii85(string, /, *, foldspaces=False, adobe=False, ignorechars=b'')
120+
.. function:: a2b_ascii85(string, /, *, foldspaces=False, adobe=False, ignorechars=b'', canonical=False)
117121

118122
Convert Ascii85 data back to binary and return the binary data.
119123

@@ -122,7 +126,8 @@ The :mod:`!binascii` module defines the following functions:
122126
characters). Each group encodes 32 bits of binary data in the range from
123127
``0`` to ``2 ** 32 - 1``, inclusive. The special character ``z`` is
124128
accepted as a short form of the group ``!!!!!``, which encodes four
125-
consecutive null bytes.
129+
consecutive null bytes. A single-character final group is always rejected
130+
as an encoding violation.
126131

127132
*foldspaces* is a flag that specifies whether the 'y' short sequence
128133
should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20).
@@ -135,6 +140,12 @@ The :mod:`!binascii` module defines the following functions:
135140
to ignore from the input.
136141
This should only contain whitespace characters.
137142

143+
If *canonical* is true, non-canonical encodings are rejected with
144+
:exc:`binascii.Error`. Here "canonical" means the encoding that
145+
:func:`b2a_ascii85` would produce: the ``z`` abbreviation must be used
146+
for all-zero groups (rather than ``!!!!!``), and partial final groups
147+
must use the same padding digits as the encoder.
148+
138149
Invalid Ascii85 data will raise :exc:`binascii.Error`.
139150

140151
.. versionadded:: 3.15
@@ -163,22 +174,28 @@ The :mod:`!binascii` module defines the following functions:
163174
.. versionadded:: 3.15
164175

165176

166-
.. function:: a2b_base85(string, /, *, alphabet=BASE85_ALPHABET, ignorechars=b'')
177+
.. function:: a2b_base85(string, /, *, alphabet=BASE85_ALPHABET, ignorechars=b'', canonical=False)
167178

168179
Convert Base85 data back to binary and return the binary data.
169180
More than one line may be passed at a time.
170181

171182
Valid Base85 data contains characters from the Base85 alphabet in groups
172183
of five (except for the final group, which may have from two to five
173184
characters). Each group encodes 32 bits of binary data in the range from
174-
``0`` to ``2 ** 32 - 1``, inclusive.
185+
``0`` to ``2 ** 32 - 1``, inclusive. A single-character final group is
186+
always rejected as an encoding violation.
175187

176188
Optional *alphabet* must be a :class:`bytes` object of length 85 which
177189
specifies an alternative alphabet.
178190

179191
*ignorechars* should be a :term:`bytes-like object` containing characters
180192
to ignore from the input.
181193

194+
If *canonical* is true, non-canonical encodings are rejected with
195+
:exc:`binascii.Error`. Here "canonical" means the encoding that
196+
:func:`b2a_base85` would produce: partial final groups must use the
197+
same padding digits as the encoder.
198+
182199
Invalid Base85 data will raise :exc:`binascii.Error`.
183200

184201
.. versionadded:: 3.15
@@ -202,7 +219,7 @@ The :mod:`!binascii` module defines the following functions:
202219
.. versionadded:: 3.15
203220

204221

205-
.. function:: a2b_base32(string, /, *, padded=True, alphabet=BASE32_ALPHABET, ignorechars=b'')
222+
.. function:: a2b_base32(string, /, *, padded=True, alphabet=BASE32_ALPHABET, ignorechars=b'', canonical=False)
206223

207224
Convert base32 data back to binary and return the binary data.
208225

@@ -231,6 +248,10 @@ The :mod:`!binascii` module defines the following functions:
231248
presented before the end of the encoded data and the excess pad characters
232249
will be ignored.
233250

251+
If *canonical* is true, non-zero padding bits in the last group are rejected
252+
with :exc:`binascii.Error`, enforcing canonical encoding as defined in
253+
:rfc:`4648` section 3.5.
254+
234255
Invalid base32 data will raise :exc:`binascii.Error`.
235256

236257
.. versionadded:: 3.15

Doc/library/dis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ operation is being performed, so the intermediate analysis object isn't useful:
400400

401401
.. versionchanged:: 3.10
402402
The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the
403-
:attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab`
403+
:attr:`~codeobject.co_firstlineno` and :attr:`!codeobject.co_lnotab`
404404
attributes of the :ref:`code object <code-objects>`.
405405

406406
.. versionchanged:: 3.13

Doc/library/inspect.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
195195
| | | read more :ref:`here |
196196
| | | <inspect-module-co-flags>`|
197197
+-----------------+-------------------+---------------------------+
198-
| | co_lnotab | encoded mapping of line |
199-
| | | numbers to bytecode |
200-
| | | indices |
201-
+-----------------+-------------------+---------------------------+
202198
| | co_freevars | tuple of names of free |
203199
| | | variables (referenced via |
204200
| | | a function's closure) |

Doc/library/profiling.sampling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
--------------
1919

20-
.. image:: tachyon-logo.png
20+
.. image:: ../../Lib/profiling/sampling/_assets/tachyon-logo.png
2121
:alt: Tachyon logo
2222
:align: center
2323
:width: 300px

Doc/library/tachyon-logo.png

-110 KB
Binary file not shown.

Doc/library/tokenize.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type can be determined by checking the ``exact_type`` property on the
2828
**undefined** when providing invalid Python code and it can change at any
2929
point.
3030

31-
Tokenizing Input
31+
Tokenizing input
3232
----------------
3333

3434
The primary entry point is a :term:`generator`:
@@ -146,7 +146,7 @@ function it uses to do this is available:
146146

147147
.. _tokenize-cli:
148148

149-
Command-Line Usage
149+
Command-line usage
150150
------------------
151151

152152
.. versionadded:: 3.3
@@ -173,8 +173,12 @@ The following options are accepted:
173173
If :file:`filename.py` is specified its contents are tokenized to stdout.
174174
Otherwise, tokenization is performed on stdin.
175175

176+
.. versionadded:: next
177+
Output is in color by default and can be
178+
:ref:`controlled using environment variables <using-on-controlling-color>`.
179+
176180
Examples
177-
------------------
181+
--------
178182

179183
Example of a script rewriter that transforms float literals into Decimal
180184
objects::
@@ -227,7 +231,7 @@ Example of tokenizing from the command line. The script::
227231

228232
will be tokenized to the following output where the first column is the range
229233
of the line/column coordinates where the token is found, the second column is
230-
the name of the token, and the final column is the value of the token (if any)
234+
the name of the token, and the final column is the value of the token (if any):
231235

232236
.. code-block:: shell-session
233237

0 commit comments

Comments
 (0)