Skip to content

Commit 93327ad

Browse files
authored
Merge branch 'main' into lazy-stuff
2 parents a45fd4d + 4ff8b07 commit 93327ad

File tree

19 files changed

+523
-153
lines changed

19 files changed

+523
-153
lines changed

.github/workflows/reusable-check-html-ids.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,45 @@ jobs:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 30
1717
steps:
18-
- name: 'Check out base commit'
18+
- name: 'Check out PR head'
1919
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2020
with:
2121
persist-credentials: false
22-
ref: ${{ github.event.pull_request.base.sha }}
22+
ref: ${{ github.event.pull_request.head.sha }}
23+
- name: 'Find merge base'
24+
id: merge-base
25+
run: |
26+
BASE="${{ github.event.pull_request.base.sha }}"
27+
HEAD="${{ github.event.pull_request.head.sha }}"
28+
git fetch --depth=$((${{ github.event.pull_request.commits }} + 10)) --no-tags origin "$BASE" "$HEAD"
29+
30+
if ! MERGE_BASE=$(git merge-base "$BASE" "$HEAD" 2>/dev/null); then
31+
git fetch --deepen=1 --no-tags origin "$BASE" "$HEAD"
32+
33+
OLDEST=$(git rev-list --reflog --max-parents=0 --reverse "${BASE}^" "${HEAD}^" | head -1)
34+
TIMESTAMP=$(git show --format=%at --no-patch "$OLDEST")
35+
36+
git fetch --shallow-since="$TIMESTAMP" --no-tags origin "$BASE" "$HEAD"
37+
38+
MERGE_BASE=$(git merge-base "$BASE" "$HEAD")
39+
fi
40+
echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT"
41+
- name: 'Create worktree at merge base'
42+
env:
43+
MERGE_BASE: ${{ steps.merge-base.outputs.sha }}
44+
run: git worktree add /tmp/merge-base "$MERGE_BASE" --detach
2345
- name: 'Set up Python'
2446
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2547
with:
2648
python-version: '3'
2749
cache: 'pip'
2850
cache-dependency-path: 'Doc/requirements.txt'
2951
- name: 'Install build dependencies'
30-
run: make -C Doc/ venv
52+
run: make -C /tmp/merge-base/Doc/ venv
3153
- name: 'Build HTML documentation'
32-
run: make -C Doc/ SPHINXOPTS="--quiet" html
33-
- name: 'Check out PR head tools'
34-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35-
with:
36-
persist-credentials: false
37-
sparse-checkout: |
38-
Doc/tools/check-html-ids.py
39-
Doc/tools/removed-ids.txt
40-
sparse-checkout-cone-mode: false
41-
path: pr-head
42-
- name: 'Use PR head tools'
43-
run: |
44-
cp pr-head/Doc/tools/check-html-ids.py Doc/tools/check-html-ids.py
45-
[ -f pr-head/Doc/tools/removed-ids.txt ] && cp pr-head/Doc/tools/removed-ids.txt Doc/tools/removed-ids.txt
54+
run: make -C /tmp/merge-base/Doc/ SPHINXOPTS="--quiet" html
4655
- name: 'Collect HTML IDs'
47-
run: python Doc/tools/check-html-ids.py collect Doc/build/html -o /tmp/html-ids-base.json.gz
56+
run: python Doc/tools/check-html-ids.py collect /tmp/merge-base/Doc/build/html -o /tmp/html-ids-base.json.gz
4857
- name: 'Download PR head HTML IDs'
4958
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
5059
with:

Doc/conf.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
# General substitutions.
7474
project = 'Python'
7575
copyright = "2001 Python Software Foundation"
76+
_doc_authors = 'Python documentation authors'
7677

7778
# We look for the Include/patchlevel.h file in the current Python source tree
7879
# and replace the values accordingly.
@@ -361,69 +362,74 @@
361362

362363
# Grouping the document tree into LaTeX files. List of tuples
363364
# (source start file, target name, title, author, document class [howto/manual]).
364-
_stdauthor = 'The Python development team'
365365
latex_documents = [
366-
('c-api/index', 'c-api.tex', 'The Python/C API', _stdauthor, 'manual'),
366+
('c-api/index', 'c-api.tex', 'The Python/C API', _doc_authors, 'manual'),
367367
(
368368
'extending/index',
369369
'extending.tex',
370370
'Extending and Embedding Python',
371-
_stdauthor,
371+
_doc_authors,
372372
'manual',
373373
),
374374
(
375375
'installing/index',
376376
'installing.tex',
377377
'Installing Python Modules',
378-
_stdauthor,
378+
_doc_authors,
379379
'manual',
380380
),
381381
(
382382
'library/index',
383383
'library.tex',
384384
'The Python Library Reference',
385-
_stdauthor,
385+
_doc_authors,
386386
'manual',
387387
),
388388
(
389389
'reference/index',
390390
'reference.tex',
391391
'The Python Language Reference',
392-
_stdauthor,
392+
_doc_authors,
393393
'manual',
394394
),
395395
(
396396
'tutorial/index',
397397
'tutorial.tex',
398398
'Python Tutorial',
399-
_stdauthor,
399+
_doc_authors,
400400
'manual',
401401
),
402402
(
403403
'using/index',
404404
'using.tex',
405405
'Python Setup and Usage',
406-
_stdauthor,
406+
_doc_authors,
407407
'manual',
408408
),
409409
(
410410
'faq/index',
411411
'faq.tex',
412412
'Python Frequently Asked Questions',
413-
_stdauthor,
413+
_doc_authors,
414414
'manual',
415415
),
416416
(
417417
'whatsnew/' + version,
418418
'whatsnew.tex',
419419
'What\'s New in Python',
420-
'A. M. Kuchling',
420+
_doc_authors,
421421
'howto',
422422
),
423423
]
424424
# Collect all HOWTOs individually
425425
latex_documents.extend(
426-
('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex', '', _stdauthor, 'howto')
426+
(
427+
'howto/' + fn[:-4],
428+
'howto-' + fn[:-4] + '.tex',
429+
'',
430+
_doc_authors,
431+
'howto',
432+
)
427433
for fn in os.listdir('howto')
428434
if fn.endswith('.rst') and fn != 'index.rst'
429435
)
@@ -434,7 +440,7 @@
434440
# Options for Epub output
435441
# -----------------------
436442

437-
epub_author = 'Python Documentation Authors'
443+
epub_author = _doc_authors
438444
epub_publisher = 'Python Software Foundation'
439445
epub_exclude_files = (
440446
'index.xhtml',

Doc/library/base64.rst

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The :rfc:`4648` encodings are suitable for encoding binary data so that it can b
5151
safely sent by email, used as parts of URLs, or included as part of an HTTP
5252
POST request.
5353

54-
.. function:: b64encode(s, altchars=None, *, wrapcol=0)
54+
.. function:: b64encode(s, altchars=None, *, padded=True, wrapcol=0)
5555

5656
Encode the :term:`bytes-like object` *s* using Base64 and return the encoded
5757
:class:`bytes`.
@@ -61,6 +61,10 @@ POST request.
6161
This allows an application to e.g. generate URL or filesystem safe Base64
6262
strings. The default is ``None``, for which the standard Base64 alphabet is used.
6363

64+
If *padded* is true (default), pad the encoded data with the '='
65+
character to a size multiple of 4.
66+
If *padded* is false, do not add the pad characters.
67+
6468
If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
6569
after at most every *wrapcol* characters.
6670
If *wrapcol* is zero (default), do not insert any newlines.
@@ -69,11 +73,11 @@ POST request.
6973
:exc:`TypeError` if *altchars* is not a :term:`bytes-like object`.
7074

7175
.. versionchanged:: 3.15
72-
Added the *wrapcol* parameter.
76+
Added the *padded* and *wrapcol* parameters.
7377

7478

75-
.. function:: b64decode(s, altchars=None, validate=False)
76-
b64decode(s, altchars=None, validate=True, *, ignorechars)
79+
.. function:: b64decode(s, altchars=None, validate=False, *, padded=True)
80+
b64decode(s, altchars=None, validate=True, *, ignorechars, padded=True)
7781
7882
Decode the Base64 encoded :term:`bytes-like object` or ASCII string
7983
*s* and return the decoded :class:`bytes`.
@@ -82,6 +86,11 @@ POST request.
8286
of length 2 which specifies the alternative alphabet used instead of the
8387
``+`` and ``/`` characters.
8488

89+
If *padded* is true, the last group of 4 base 64 alphabet characters must
90+
be padded with the '=' character.
91+
If *padded* is false, the '=' character is treated as other non-alphabet
92+
characters (depending on the value of *validate* and *ignorechars*).
93+
8594
A :exc:`binascii.Error` exception is raised
8695
if *s* is incorrectly padded.
8796

@@ -106,7 +115,7 @@ POST request.
106115
For more information about the strict base64 check, see :func:`binascii.a2b_base64`
107116

108117
.. versionchanged:: 3.15
109-
Added the *ignorechars* parameter.
118+
Added the *ignorechars* and *padded* parameters.
110119

111120
.. deprecated:: 3.15
112121
Accepting the ``+`` and ``/`` characters with an alternative alphabet
@@ -125,41 +134,52 @@ POST request.
125134
Base64 alphabet and return the decoded :class:`bytes`.
126135

127136

128-
.. function:: urlsafe_b64encode(s)
137+
.. function:: urlsafe_b64encode(s, *, padded=True)
129138

130139
Encode :term:`bytes-like object` *s* using the
131140
URL- and filesystem-safe alphabet, which
132141
substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the
133142
standard Base64 alphabet, and return the encoded :class:`bytes`. The result
134-
can still contain ``=``.
143+
can still contain ``=`` if *padded* is true (default).
144+
145+
.. versionchanged:: next
146+
Added the *padded* parameter.
135147

136148

137-
.. function:: urlsafe_b64decode(s)
149+
.. function:: urlsafe_b64decode(s, *, padded=False)
138150

139151
Decode :term:`bytes-like object` or ASCII string *s*
140152
using the URL- and filesystem-safe
141153
alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of
142154
``/`` in the standard Base64 alphabet, and return the decoded
143155
:class:`bytes`.
144156

157+
.. versionchanged:: next
158+
Added the *padded* parameter.
159+
Padding of input is no longer required by default.
160+
145161
.. deprecated:: 3.15
146162
Accepting the ``+`` and ``/`` characters is now deprecated.
147163

148164

149-
.. function:: b32encode(s, *, wrapcol=0)
165+
.. function:: b32encode(s, *, padded=True, wrapcol=0)
150166

151167
Encode the :term:`bytes-like object` *s* using Base32 and return the
152168
encoded :class:`bytes`.
153169

170+
If *padded* is true (default), pad the encoded data with the '='
171+
character to a size multiple of 8.
172+
If *padded* is false, do not add the pad characters.
173+
154174
If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
155175
after at most every *wrapcol* characters.
156176
If *wrapcol* is zero (default), do not add any newlines.
157177

158178
.. versionchanged:: next
159-
Added the *wrapcol* parameter.
179+
Added the *padded* and *wrapcol* parameters.
160180

161181

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

164184
Decode the Base32 encoded :term:`bytes-like object` or ASCII string *s* and
165185
return the decoded :class:`bytes`.
@@ -175,6 +195,11 @@ POST request.
175195
digit 0 is always mapped to the letter O). For security purposes the default is
176196
``None``, so that 0 and 1 are not allowed in the input.
177197

198+
If *padded* is true, the last group of 8 base 32 alphabet characters must
199+
be padded with the '=' character.
200+
If *padded* is false, the '=' character is treated as other non-alphabet
201+
characters (depending on the value of *ignorechars*).
202+
178203
*ignorechars* should be a :term:`bytes-like object` containing characters
179204
to ignore from the input.
180205

@@ -183,21 +208,21 @@ POST request.
183208
input.
184209

185210
.. versionchanged:: next
186-
Added the *ignorechars* parameter.
211+
Added the *ignorechars* and *padded* parameters.
187212

188213

189-
.. function:: b32hexencode(s, *, wrapcol=0)
214+
.. function:: b32hexencode(s, *, padded=True, wrapcol=0)
190215

191216
Similar to :func:`b32encode` but uses the Extended Hex Alphabet, as defined in
192217
:rfc:`4648`.
193218

194219
.. versionadded:: 3.10
195220

196221
.. versionchanged:: next
197-
Added the *wrapcol* parameter.
222+
Added the *padded* and *wrapcol* parameters.
198223

199224

200-
.. function:: b32hexdecode(s, casefold=False, *, ignorechars=b'')
225+
.. function:: b32hexdecode(s, casefold=False, *, padded=True, ignorechars=b'')
201226

202227
Similar to :func:`b32decode` but uses the Extended Hex Alphabet, as defined in
203228
:rfc:`4648`.
@@ -210,7 +235,7 @@ POST request.
210235
.. versionadded:: 3.10
211236

212237
.. versionchanged:: next
213-
Added the *ignorechars* parameter.
238+
Added the *ignorechars* and *padded* parameters.
214239

215240

216241
.. function:: b16encode(s, *, wrapcol=0)

0 commit comments

Comments
 (0)