MCPcopy Index your code
hub / github.com/python/cpython / checkline

Method checkline

Lib/pdb.py:1530–1551  ·  view source on GitHub ↗

Check whether specified line seems to be executable. Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank line or EOF). Warning: testing is not comprehensive.

(self, filename, lineno, module_globals=None)

Source from the content-addressed store, hash-verified

1528 return answer or failed
1529
1530 def checkline(self, filename, lineno, module_globals=None):
1531 """Check whether specified line seems to be executable.
1532
1533 Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
1534 line or EOF). Warning: testing is not comprehensive.
1535 """
1536 # this method should be callable before starting debugging, so default
1537 # to "no globals" if there is no current frame
1538 frame = self.curframe
1539 if module_globals is None:
1540 module_globals = frame.f_globals if frame else None
1541 line = linecache.getline(filename, lineno, module_globals)
1542 if not line:
1543 self.message('End of file')
1544 return 0
1545 line = line.strip()
1546 # Don't allow setting breakpoint at a blank line
1547 if (not line or (line[0] == '#') or
1548 (line[:3] == '"""') or line[:3] == "'''"):
1549 self.error('Blank or comment')
1550 return 0
1551 return lineno
1552
1553 def do_enable(self, arg):
1554 """enable bpnumber [bpnumber ...]

Callers 4

do_breakMethod · 0.95

Calls 4

messageMethod · 0.95
errorMethod · 0.95
getlineMethod · 0.45
stripMethod · 0.45