MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / do_list

Method do_list

tools/python-3.11.9-amd64/Lib/pdb.py:1284–1338  ·  view source on GitHub ↗

l(ist) [first [,last] | .] List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. With . as argument, list 11 lines around the current line. With one argument, list 11 lines starting a

(self, arg)

Source from the content-addressed store, hash-verified

1282 complete_pp = _complete_expression
1283
1284 def do_list(self, arg):
1285 """l(ist) [first [,last] | .]
1286
1287 List source code for the current file. Without arguments,
1288 list 11 lines around the current line or continue the previous
1289 listing. With . as argument, list 11 lines around the current
1290 line. With one argument, list 11 lines starting at that line.
1291 With two arguments, list the given range; if the second
1292 argument is less than the first, it is a count.
1293
1294 The current line in the current frame is indicated by "->".
1295 If an exception is being debugged, the line where the
1296 exception was originally raised or propagated is indicated by
1297 ">>", if it differs from the current line.
1298 """
1299 self.lastcmd = 'list'
1300 last = None
1301 if arg and arg != '.':
1302 try:
1303 if ',' in arg:
1304 first, last = arg.split(',')
1305 first = int(first.strip())
1306 last = int(last.strip())
1307 if last < first:
1308 # assume it's a count
1309 last = first + last
1310 else:
1311 first = int(arg.strip())
1312 first = max(1, first - 5)
1313 except ValueError:
1314 self.error('Error in argument: %r' % arg)
1315 return
1316 elif self.lineno is None or arg == '.':
1317 first = max(1, self.curframe.f_lineno - 5)
1318 else:
1319 first = self.lineno + 1
1320 if last is None:
1321 last = first + 10
1322 filename = self.curframe.f_code.co_filename
1323 # gh-93696: stdlib frozen modules provide a useful __file__
1324 # this workaround can be removed with the closure of gh-89815
1325 if filename.startswith("<frozen"):
1326 tmp = self.curframe.f_globals.get("__file__")
1327 if isinstance(tmp, str):
1328 filename = tmp
1329 breaklist = self.get_file_breaks(filename)
1330 try:
1331 lines = linecache.getlines(filename, self.curframe.f_globals)
1332 self._print_lines(lines[first-1:last], first, breaklist,
1333 self.curframe)
1334 self.lineno = min(last, len(lines))
1335 if len(lines) < last:
1336 self.message('[EOF]')
1337 except KeyboardInterrupt:
1338 pass
1339 do_l = do_list
1340
1341 def do_longlist(self, arg):

Callers

nothing calls this directly

Calls 10

errorMethod · 0.95
_print_linesMethod · 0.95
messageMethod · 0.95
maxFunction · 0.85
minFunction · 0.85
stripMethod · 0.80
startswithMethod · 0.80
get_file_breaksMethod · 0.80
splitMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected