Skip to content

Commit d26e9b7

Browse files
committed
Merge in the main branch
2 parents ba6e602 + 058bc18 commit d26e9b7

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@
359359
'papersize': 'a4paper',
360360
# The font size ('10pt', '11pt' or '12pt').
361361
'pointsize': '10pt',
362+
'maxlistdepth': '8', # See https://github.com/python/cpython/issues/139588
362363
}
363364

364365
# Grouping the document tree into LaTeX files. List of tuples

Lib/linecache.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ def updatecache(filename, module_globals=None):
123123
if _source_unavailable(filename):
124124
return []
125125

126-
if filename.startswith('<frozen ') and module_globals is not None:
126+
if filename.startswith('<frozen '):
127127
# This is a frozen module, so we need to use the filename
128128
# from the module globals.
129+
if module_globals is None:
130+
return []
131+
129132
fullname = module_globals.get('__file__')
130133
if fullname is None:
131134
return []

Lib/pdb.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3577,7 +3577,13 @@ def main():
35773577
parser.error("argument -m: not allowed with argument --pid")
35783578
try:
35793579
attach(opts.pid, opts.commands)
3580-
except PermissionError as e:
3580+
except RuntimeError:
3581+
print(
3582+
f"Cannot attach to pid {opts.pid}, please make sure that the process exists "
3583+
"and is using the same Python version."
3584+
)
3585+
sys.exit(1)
3586+
except PermissionError:
35813587
exit_with_permission_help_text()
35823588
return
35833589
elif opts.module:

Lib/test/test_remote_pdb.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,5 +1590,17 @@ def test_attach_to_process_with_colors(self):
15901590
self.assertNotIn("while x == 1", output["client"]["stdout"])
15911591
self.assertIn("while x == 1", re.sub("\x1b[^m]*m", "", output["client"]["stdout"]))
15921592

1593+
def test_attach_to_non_existent_process(self):
1594+
with force_color(False):
1595+
result = subprocess.run([sys.executable, "-m", "pdb", "-p", "999999"], text=True, capture_output=True)
1596+
self.assertNotEqual(result.returncode, 0)
1597+
if sys.platform == "darwin":
1598+
# On MacOS, attaching to a non-existent process gives PermissionError
1599+
error = "The specified process cannot be attached to due to insufficient permissions"
1600+
else:
1601+
error = "Cannot attach to pid 999999, please make sure that the process exists"
1602+
self.assertIn(error, result.stdout)
1603+
1604+
15931605
if __name__ == "__main__":
15941606
unittest.main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Print clearer error message when using ``pdb`` to attach to a non-existing process.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid making unnecessary filesystem calls for frozen modules in :mod:`linecache` when the global module cache is not present.

0 commit comments

Comments
 (0)