Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/inspect.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Get useful information from live Python objects.

This module encapsulates the interface provided by the internal special
attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion.
attributes (co_*, tb_*, etc.) in a friendlier fashion.
It also provides some help for examining source code and class layout.

Here are some of the useful functions provided by this module:
Expand Down
4 changes: 4 additions & 0 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3809,6 +3809,10 @@ def parse_args():
opt_module = parser.parse_args(args[:2])
opts.module = opt_module.module
args = args[2:]
elif args[0] == '--':
args.pop(0)
if not args:
parser.error("missing script or module to run")
elif args[0].startswith('-'):
# Invalid argument before the script name.
invalid_args = list(itertools.takewhile(lambda a: a.startswith('-'), args))
Expand Down
21 changes: 21 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4718,6 +4718,27 @@ def bar():
]))
self.assertIn('break in bar', stdout)

def test_end_of_options_separator(self):
# gh-148615: Test parsing when '--' separator is used
script = "import sys; print(f'ARGS: {sys.argv[1:]}')"
with open(os_helper.TESTFN, 'w', encoding='utf-8') as f:
f.write(script)
stdout, _ = self._run_pdb(['--', os_helper.TESTFN, '-foo'], 'c\nq')
self.assertIn("ARGS: ['-foo']", stdout)
stdout, _ = self._run_pdb(['-c', 'continue', '--', os_helper.TESTFN, '-c', 'foo'], 'q')
self.assertIn("ARGS: ['-c', 'foo']", stdout)
stdout, stderr = self._run_pdb(['--'], 'q', expected_returncode=2)
self.assertIn("missing script or module to run", stderr)
stdout, stderr = self._run_pdb(['-x', '--', os_helper.TESTFN], 'q', expected_returncode=2)
self.assertIn("unrecognized arguments: -x", stderr)
stdout, _ = self._run_pdb([os_helper.TESTFN, '--', 'arg'], 'c\nq')
self.assertIn("ARGS: ['--', 'arg']", stdout)
with os_helper.temp_cwd():
with open('mymod.py', 'w', encoding='utf-8') as f:
f.write(script)
stdout, _ = self._run_pdb(['-m', 'mymod', '--', 'arg'], 'c\nq')
self.assertIn("ARGS: ['--', 'arg']", stdout)

@unittest.skipIf(SKIP_CORO_TESTS, "Coroutine tests are skipped")
def test_async_break(self):
script = """
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :mod:`pdb` to accept standard -- end of options separator. Reported by haampie. Patched by Shrey Naithani.
8 changes: 4 additions & 4 deletions PCbuild/tcltk.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
<tclDir Condition="$(tclDir) == ''">$(ExternalsDir)tcl-core-$(TclVersion)\</tclDir>
<tkDir Condition="$(tkDir) == ''">$(ExternalsDir)tk-$(TkVersion)\</tkDir>
<tcltkDir Condition="$(tcltkDir) == ''">$(ExternalsDir)tcltk-$(TclVersion)\$(ArchName)\</tcltkDir>
<tclWin32Exe Condition="$(Platform) == 'Win32'">$(tcltkDir)\bin\tclsh$(TclMajorVersion)$(TclMinorVersion)t.exe</tclWin32Exe>
<tclWin32Exe Condition="$(Platform) != 'Win32'">$(tcltkDir)\..\win32\bin\tclsh$(TclMajorVersion)$(TclMinorVersion)t.exe</tclWin32Exe>
<tcltkSuffix Condition="'$(TclMajorVersion)' == '8'">t</tcltkSuffix>
<tkPrefix Condition="'$(TclMajorVersion)' == '9'">tcl9</tkPrefix>
<tclWin32Exe Condition="$(Platform) == 'Win32'">$(tcltkDir)\bin\tclsh$(TclMajorVersion)$(TclMinorVersion)$(tcltkSuffix).exe</tclWin32Exe>
<tclWin32Exe Condition="$(Platform) != 'Win32'">$(tcltkDir)\..\win32\bin\tclsh$(TclMajorVersion)$(TclMinorVersion)$(tcltkSuffix).exe</tclWin32Exe>
<tclExternalTommath Condition="$(TclMajorVersion) == '9'">TCL_WITH_EXTERNAL_TOMMATH;</tclExternalTommath>

<!--<TclDebugExt Condition="'$(Configuration)' == 'Debug'">g</TclDebugExt>-->
<tcltkSuffix Condition="'$(TclMajorVersion)' == '8'">t</tcltkSuffix>
<tkPrefix Condition="'$(TclMajorVersion)' == '9'">tcl9</tkPrefix>
<tclDLLName >tcl$(TclMajorVersion)$(TclMinorVersion)$(tcltkSuffix)$(TclDebugExt).dll</tclDLLName>
<tclLibName>tcl$(TclMajorVersion)$(TclMinorVersion)$(tcltkSuffix)$(TclDebugExt).lib</tclLibName>
<tclShExeName>tclsh$(TclMajorVersion)$(TclMinorVersion)$(tcltkSuffix)$(TclDebugExt).exe</tclShExeName>
Expand Down
Loading