Skip to content

Commit 7fac516

Browse files
Deploy preview for PR 1231 🛫
1 parent b82da3b commit 7fac516

585 files changed

Lines changed: 802 additions & 614 deletions

File tree

Some content is hidden

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

pr-preview/pr-1231/_sources/library/argparse.rst.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,8 @@ is considered equivalent to the expression ``['-f', 'foo', '-f', 'bar']``.
442442

443443
.. note::
444444

445-
Empty lines are treated as empty strings (``''``), which are allowed as values but
446-
not as arguments. Empty lines that are read as arguments will result in an
447-
"unrecognized arguments" error.
445+
Each line is treated as a single argument, so an empty line is read as an
446+
empty string (``''``).
448447

449448
:class:`ArgumentParser` uses :term:`filesystem encoding and error handler`
450449
to read the file containing arguments.
@@ -1048,6 +1047,10 @@ is used when no command-line argument was present::
10481047
>>> parser.parse_args([])
10491048
Namespace(foo=42)
10501049

1050+
Because ``nargs='*'`` gathers any supplied values into a list, an absent
1051+
positional argument yields an empty list (``[]``). Only a non-``None``
1052+
*default* overrides this (so ``default=None`` still gives ``[]``).
1053+
10511054
For required_ arguments, the ``default`` value is ignored. For example, this
10521055
applies to positional arguments with nargs_ values other than ``?`` or ``*``,
10531056
or optional arguments marked as ``required=True``.
@@ -1360,6 +1363,10 @@ behavior::
13601363
>>> parser.parse_args('--foo XXX'.split())
13611364
Namespace(bar='XXX')
13621365

1366+
Multiple arguments may share the same ``dest``. By default, the value from the
1367+
last such argument given on the command line wins. Use ``action='append'`` to
1368+
collect values from all of them into a list instead. For conflicting *option
1369+
strings* rather than ``dest`` names, see conflict_handler_.
13631370

13641371
.. _deprecated:
13651372

@@ -1755,6 +1762,11 @@ Subcommands
17551762
present, and when the ``b`` command is specified, only the ``foo`` and
17561763
``baz`` attributes are present.
17571764

1765+
If a subparser defines an argument with the same ``dest`` as the parent
1766+
parser, the two share a single namespace attribute, so the parent's value
1767+
won't be retained. Users should give them distinct ``dest`` values to
1768+
keep both.
1769+
17581770
Similarly, when a help message is requested from a subparser, only the help
17591771
for that particular parser will be printed. The help message will not
17601772
include parent parser or sibling parser messages. (A help message for each
@@ -2199,6 +2211,9 @@ Customizing file parsing
21992211
def convert_arg_line_to_args(self, arg_line):
22002212
return arg_line.split()
22012213

2214+
Note that with this override an argument can no longer contain spaces, since
2215+
each space-separated word becomes a separate argument.
2216+
22022217

22032218
Exiting methods
22042219
^^^^^^^^^^^^^^^

pr-preview/pr-1231/_sources/library/pyexpat.rst.txt

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,71 @@ XMLParser Objects
238238
.. versionadded:: 3.13
239239

240240

241-
:class:`!xmlparser` objects have the following methods to mitigate some
242-
common XML vulnerabilities.
241+
:class:`!xmlparser` objects have the following methods to tune protections
242+
against some common XML vulnerabilities.
243+
244+
.. method:: xmlparser.SetBillionLaughsAttackProtectionActivationThreshold(threshold, /)
245+
246+
Sets the number of output bytes needed to activate protection against
247+
`billion laughs`_ attacks.
248+
249+
The number of output bytes includes amplification from entity expansion
250+
and reading DTD files.
251+
252+
Parser objects usually have a protection activation threshold of 8 MiB,
253+
but the actual default value depends on the underlying Expat library.
254+
255+
An :exc:`ExpatError` is raised if this method is called on a
256+
|xml-non-root-parser| parser.
257+
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
258+
should not be used as they may have no special meaning.
259+
260+
.. note::
261+
262+
Activation thresholds below 4 MiB are known to break support for DITA 1.3
263+
payload and are hence not recommended.
264+
265+
.. versionadded:: next
266+
267+
.. method:: xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor, /)
268+
269+
Sets the maximum tolerated amplification factor for protection against
270+
`billion laughs`_ attacks.
271+
272+
The amplification factor is calculated as ``(direct + indirect) / direct``
273+
while parsing, where ``direct`` is the number of bytes read from
274+
the primary document in parsing and ``indirect`` is the number of
275+
bytes added by expanding entities and reading of external DTD files.
276+
277+
The *max_factor* value must be a non-NaN :class:`float` value greater than
278+
or equal to 1.0. Peak amplifications of factor 15,000 for the entire payload
279+
and of factor 30,000 in the middle of parsing have been observed with small
280+
benign files in practice. In particular, the activation threshold should be
281+
carefully chosen to avoid false positives.
282+
283+
Parser objects usually have a maximum amplification factor of 100,
284+
but the actual default value depends on the underlying Expat library.
285+
286+
An :exc:`ExpatError` is raised if this method is called on a
287+
|xml-non-root-parser| parser or if *max_factor* is outside the valid range.
288+
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
289+
should not be used as they may have no special meaning.
290+
291+
.. note::
292+
293+
The maximum amplification factor is only considered if the threshold
294+
that can be adjusted by :meth:`.SetBillionLaughsAttackProtectionActivationThreshold`
295+
is exceeded.
296+
297+
.. versionadded:: next
243298

244299
.. method:: xmlparser.SetAllocTrackerActivationThreshold(threshold, /)
245300

246301
Sets the number of allocated bytes of dynamic memory needed to activate
247302
protection against disproportionate use of RAM.
248303

249-
By default, parser objects have an allocation activation threshold of 64 MiB,
250-
or equivalently 67,108,864 bytes.
304+
Parser objects usually have an allocation activation threshold of 64 MiB,
305+
but the actual default value depends on the underlying Expat library.
251306

252307
An :exc:`ExpatError` is raised if this method is called on a
253308
|xml-non-root-parser| parser.
@@ -271,7 +326,8 @@ common XML vulnerabilities.
271326
near the start of parsing even with benign files in practice. In particular,
272327
the activation threshold should be carefully chosen to avoid false positives.
273328

274-
By default, parser objects have a maximum amplification factor of 100.0.
329+
Parser objects usually have a maximum amplification factor of 100,
330+
but the actual default value depends on the underlying Expat library.
275331

276332
An :exc:`ExpatError` is raised if this method is called on a
277333
|xml-non-root-parser| parser or if *max_factor* is outside the valid range.
@@ -1019,4 +1075,6 @@ The ``errors`` module has the following attributes:
10191075
not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl
10201076
and https://www.iana.org/assignments/character-sets/character-sets.xhtml.
10211077
1078+
1079+
.. _billion laughs: https://en.wikipedia.org/wiki/Billion_laughs_attack
10221080
.. |xml-non-root-parser| replace:: :ref:`non-root <xmlparser-non-root>`

pr-preview/pr-1231/_sources/library/shutil.rst.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,14 @@ Directory and files operations
388388
If *dst* already exists but is not a directory, it may be overwritten
389389
depending on :func:`os.rename` semantics.
390390

391-
If the destination is on the current filesystem, then :func:`os.rename` is
392-
used. Otherwise, *src* is copied to the destination using *copy_function*
393-
and then removed. In case of symlinks, a new symlink pointing to the target
394-
of *src* will be created as the destination and *src* will be removed.
391+
:func:`os.rename` is preferably used internally when *src* and the destination are on
392+
the same filesystem. In case :func:`os.rename` fails due to :exc:`OSError`
393+
(e.g. the user has write permission to the destination file but not to its parent
394+
directory), this method falls back to using *copy_function*, in which case
395+
*src* is copied to the destination using *copy_function* and then removed.
396+
397+
In case of symlinks, a new symlink pointing to the target of *src* will be
398+
created in or as the destination, and *src* will be removed.
395399

396400
If *copy_function* is given, it must be a callable that takes two arguments,
397401
*src* and the destination, and will be used to copy *src* to the destination

pr-preview/pr-1231/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ <h3>導航</h3>
356356
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
357357
<br>
358358
<br>
359-
最後更新於 6月 09, 2026 (00:43 UTC)。
359+
最後更新於 6月 10, 2026 (00:49 UTC)。
360360

361361
<a href="/bugs.html">發現 bug</a>
362362

pr-preview/pr-1231/bugs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ <h2>說明文件的錯誤<a class="headerlink" href="#documentation-bugs" title=
250250
</section>
251251
<section id="getting-started-contributing-to-python-yourself">
252252
<span id="contributing-to-python"></span><h2>開始讓自己貢獻 Python<a class="headerlink" href="#getting-started-contributing-to-python-yourself" title="連結到這個標頭"></a></h2>
253-
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在 <a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<a class="reference external" href="https://devguide.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
253+
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在 <a class="reference external" href="https://devguide.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
254254
</section>
255255
</section>
256256

@@ -393,7 +393,7 @@ <h3>導航</h3>
393393
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
394394
<br>
395395
<br>
396-
最後更新於 6月 09, 2026 (00:43 UTC)。
396+
最後更新於 6月 10, 2026 (00:49 UTC)。
397397

398398
<a href="/bugs.html">發現 bug</a>
399399

pr-preview/pr-1231/c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ <h3>導航</h3>
365365
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
366366
<br>
367367
<br>
368-
最後更新於 6月 09, 2026 (00:43 UTC)。
368+
最後更新於 6月 10, 2026 (00:49 UTC)。
369369

370370
<a href="/bugs.html">發現 bug</a>
371371

pr-preview/pr-1231/c-api/allocation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ <h3>導航</h3>
577577
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
578578
<br>
579579
<br>
580-
最後更新於 6月 09, 2026 (00:43 UTC)。
580+
最後更新於 6月 10, 2026 (00:49 UTC)。
581581

582582
<a href="/bugs.html">發現 bug</a>
583583

pr-preview/pr-1231/c-api/apiabiversion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ <h3>導航</h3>
514514
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
515515
<br>
516516
<br>
517-
最後更新於 6月 09, 2026 (00:43 UTC)。
517+
最後更新於 6月 10, 2026 (00:49 UTC)。
518518

519519
<a href="/bugs.html">發現 bug</a>
520520

pr-preview/pr-1231/c-api/arg.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ <h3>導航</h3>
996996
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
997997
<br>
998998
<br>
999-
最後更新於 6月 09, 2026 (00:43 UTC)。
999+
最後更新於 6月 10, 2026 (00:49 UTC)。
10001000

10011001
<a href="/bugs.html">發現 bug</a>
10021002

pr-preview/pr-1231/c-api/bool.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ <h3>導航</h3>
376376
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
377377
<br>
378378
<br>
379-
最後更新於 6月 09, 2026 (00:43 UTC)。
379+
最後更新於 6月 10, 2026 (00:49 UTC)。
380380

381381
<a href="/bugs.html">發現 bug</a>
382382

0 commit comments

Comments
 (0)