-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-21161: pdb: default: handle list comprehensions #15194
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1562,6 +1562,32 @@ def test_errors_in_command(self): | |
'(Pdb) ', | ||
]) | ||
|
||
def test_list_comprehensions(self): | ||
script = """ | ||
def f(): | ||
mylocal = "init_mylocal" # noqa: F841 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the comment mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Local variable name is assigned to but never used (F841) |
||
import pdb; pdb.Pdb(readrc=False).set_trace() | ||
print("SUCCESS") | ||
|
||
f() | ||
""" | ||
commands = """ | ||
continue | ||
|
||
p "mylocal:" + mylocal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need this line in the test? |
||
["mylocal_1:%s" % mylocal for x in range(1)] | ||
mylocal = 42 | ||
["mylocal_2:%s" % mylocal for x in range(1)] | ||
|
||
continue | ||
""" | ||
stdout, stderr = self.run_pdb_module(script, commands) | ||
lines = stdout.splitlines() | ||
self.assertTrue(any("['mylocal_1:init_mylocal']" in l for l in lines), stdout) | ||
self.assertTrue(any("['mylocal_2:42']" in l for l in lines), stdout) | ||
self.assertTrue(all("NameError" not in l for l in lines), stdout) | ||
self.assertTrue(any("SUCCESS" in l for l in lines), stdout) | ||
|
||
def load_tests(*args): | ||
from test import test_pdb | ||
suites = [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What it the code that is being debugged changes
globals()
? This would mean any changes to self.curframe.f_globals by the calling code is dropped, is it not?