File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1352,6 +1352,9 @@ def do_longlist(self, arg):
1352
1352
breaklist = self .get_file_breaks (filename )
1353
1353
try :
1354
1354
lines , lineno = inspect .getsourcelines (self .curframe )
1355
+ # inspect.getsourcelines() returns 0 for module-level frame
1356
+ # and it does not make sense for the code display
1357
+ lineno = max (1 , lineno )
1355
1358
except OSError as err :
1356
1359
self .error (err )
1357
1360
return
@@ -1368,6 +1371,9 @@ def do_source(self, arg):
1368
1371
return
1369
1372
try :
1370
1373
lines , lineno = inspect .getsourcelines (obj )
1374
+ # inspect.getsourcelines() returns 0 for module-level frame
1375
+ # and it does not make sense for the code display
1376
+ lineno = max (1 , lineno )
1371
1377
except (OSError , TypeError ) as err :
1372
1378
self .error (err )
1373
1379
return
Original file line number Diff line number Diff line change @@ -1675,6 +1675,31 @@ def test_pdb_issue_gh_101673():
1675
1675
(Pdb) continue
1676
1676
"""
1677
1677
1678
+ def test_pdb_issue_gh_103225 ():
1679
+ """See GH-103225
1680
+
1681
+ Make sure longlist uses 1-based line numbers in frames that correspond to a module
1682
+
1683
+ >>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
1684
+ ... 'longlist',
1685
+ ... 'continue'
1686
+ ... ]):
1687
+ ... a = 1
1688
+ ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
1689
+ ... b = 2
1690
+ > <doctest test.test_pdb.test_pdb_issue_gh_103225[0]>(7)<module>()
1691
+ -> b = 2
1692
+ (Pdb) longlist
1693
+ 1 with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
1694
+ 2 'longlist',
1695
+ 3 'continue'
1696
+ 4 ]):
1697
+ 5 a = 1
1698
+ 6 import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
1699
+ 7 -> b = 2
1700
+ (Pdb) continue
1701
+ """
1702
+
1678
1703
1679
1704
@support .requires_subprocess ()
1680
1705
class PdbTestCase (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments