Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[3.12] gh-100141: Allow pdb to deal with empty file (GH-125425) #125537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2024
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
3 changes: 1 addition & 2 deletions 3 Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ def user_call(self, frame, argument_list):
def user_line(self, frame):
"""This function is called when we stop or break at this line."""
if self._wait_for_mainpyfile:
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
or frame.f_lineno <= 0):
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)):
return
self._wait_for_mainpyfile = False
if self.bp_commands(frame):
Expand Down
10 changes: 10 additions & 0 deletions 10 Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,16 @@ def _create_fake_frozen_module():
# verify that pdb found the source of the "frozen" function
self.assertIn('x = "Sentinel string for gh-93696"', stdout, "Sentinel statement not found")

def test_empty_file(self):
script = ''
commands = 'q\n'
# We check that pdb stopped at line 0, but anything reasonable
# is acceptable here, as long as it does not halt
stdout, _ = self.run_pdb_script(script, commands)
self.assertIn('main.py(0)', stdout)
stdout, _ = self.run_pdb_module(script, commands)
self.assertIn('__main__.py(0)', stdout)

def test_non_utf8_encoding(self):
script_dir = os.path.join(os.path.dirname(__file__), 'encoded_modules')
for filename in os.listdir(script_dir):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the bug where :mod:`pdb` will be stuck in an infinite loop when debugging an empty file.
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.