Skip to content

Commit 3a17ebe

Browse files
committed
Merge branch 'main' into gh-130614-test-join
2 parents 771aeb9 + bbd6d17 commit 3a17ebe

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

Doc/library/pdb.rst

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,34 @@ The debugger's prompt is ``(Pdb)``, which is the indicator that you are in debug
7575
arguments of the ``p`` command.
7676

7777

78+
.. program:: pdb
79+
7880
You can also invoke :mod:`pdb` from the command line to debug other scripts. For
7981
example::
8082

81-
python -m pdb myscript.py
83+
python -m pdb [-c command] (-m module | pyfile) [args ...]
8284

8385
When invoked as a module, pdb will automatically enter post-mortem debugging if
8486
the program being debugged exits abnormally. After post-mortem debugging (or
8587
after normal exit of the program), pdb will restart the program. Automatic
8688
restarting preserves pdb's state (such as breakpoints) and in most cases is more
8789
useful than quitting the debugger upon program's exit.
8890

89-
.. versionchanged:: 3.2
90-
Added the ``-c`` option to execute commands as if given
91-
in a :file:`.pdbrc` file; see :ref:`debugger-commands`.
91+
.. option:: -c, --command <command>
9292

93-
.. versionchanged:: 3.7
94-
Added the ``-m`` option to execute modules similar to the way
95-
``python -m`` does. As with a script, the debugger will pause execution just
96-
before the first line of the module.
93+
To execute commands as if given in a :file:`.pdbrc` file; see
94+
:ref:`debugger-commands`.
95+
96+
.. versionchanged:: 3.2
97+
Added the ``-c`` option.
98+
99+
.. option:: -m <module>
100+
101+
To execute modules similar to the way ``python -m`` does. As with a script,
102+
the debugger will pause execution just before the first line of the module.
103+
104+
.. versionchanged:: 3.7
105+
Added the ``-m`` option.
97106

98107
Typical usage to execute a statement under control of the debugger is::
99108

Doc/library/webbrowser.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,23 @@ a new tab, with the browser being brought to the foreground. The use of the
4040
:mod:`webbrowser` module on iOS requires the :mod:`ctypes` module. If
4141
:mod:`ctypes` isn't available, calls to :func:`.open` will fail.
4242

43+
.. program:: webbrowser
44+
4345
The script :program:`webbrowser` can be used as a command-line interface for the
4446
module. It accepts a URL as the argument. It accepts the following optional
4547
parameters:
4648

47-
* ``-n``/``--new-window`` opens the URL in a new browser window, if possible.
48-
* ``-t``/``--new-tab`` opens the URL in a new browser page ("tab").
49+
.. option:: -n, --new-window
50+
51+
Opens the URL in a new browser window, if possible.
52+
53+
.. option:: -t, --new-tab
54+
55+
Opens the URL in a new browser tab.
56+
57+
The options are, naturally, mutually exclusive. Usage example:
4958

50-
The options are, naturally, mutually exclusive. Usage example::
59+
.. code-block:: bash
5160
5261
python -m webbrowser -t "https://www.python.org"
5362

Doc/library/zipfile.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,14 @@ Path Objects
554554
e.g. 'dir/file.txt', 'dir/', or ''. Defaults to the empty string,
555555
indicating the root.
556556

557+
.. note::
558+
The :class:`Path` class does not sanitize filenames within the ZIP archive. Unlike
559+
the :meth:`ZipFile.extract` and :meth:`ZipFile.extractall` methods, it is the
560+
caller's responsibility to validate or sanitize filenames to prevent path traversal
561+
vulnerabilities (e.g., filenames containing ".." or absolute paths). When handling
562+
untrusted archives, consider resolving filenames using :func:`os.path.abspath`
563+
and checking against the target directory with :func:`os.path.commonpath`.
564+
557565
Path objects expose the following features of :mod:`pathlib.Path`
558566
objects:
559567

Lib/pathlib/types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from glob import _PathGlobber, _no_recurse_symlinks
1515
from pathlib import PurePath, Path
1616
from pathlib._os import magic_open, ensure_distinct_paths, copy_file
17-
from typing import Protocol, runtime_checkable
17+
from typing import Optional, Protocol, runtime_checkable
1818

1919

2020
def _explode_path(path):
@@ -44,6 +44,7 @@ class _PathParser(Protocol):
4444
"""
4545

4646
sep: str
47+
altsep: Optional[str]
4748
def split(self, path: str) -> tuple[str, str]: ...
4849
def splitext(self, path: str) -> tuple[str, str]: ...
4950
def normcase(self, path: str) -> str: ...
@@ -136,8 +137,7 @@ def with_name(self, name):
136137
if split(name)[0]:
137138
raise ValueError(f"Invalid name {name!r}")
138139
path = str(self)
139-
old_name = split(path)[1]
140-
path = path[:len(path) - len(old_name)] + name
140+
path = path.removesuffix(split(path)[1]) + name
141141
return self.with_segments(path)
142142

143143
def with_stem(self, stem):
@@ -226,7 +226,7 @@ def full_match(self, pattern, *, case_sensitive=None):
226226
if case_sensitive is None:
227227
case_sensitive = self.parser.normcase('Aa') == 'Aa'
228228
globber = _PathGlobber(pattern.parser.sep, case_sensitive, recursive=True)
229-
match = globber.compile(str(pattern), altsep=self.parser.altsep)
229+
match = globber.compile(str(pattern), altsep=pattern.parser.altsep)
230230
return match(str(self)) is not None
231231

232232

0 commit comments

Comments
 (0)