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)
| 810 | return answer or failed |
| 811 | |
| 812 | def checkline(self, filename, lineno): |
| 813 | """Check whether specified line seems to be executable. |
| 814 | |
| 815 | Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank |
| 816 | line or EOF). Warning: testing is not comprehensive. |
| 817 | """ |
| 818 | # this method should be callable before starting debugging, so default |
| 819 | # to "no globals" if there is no current frame |
| 820 | frame = getattr(self, 'curframe', None) |
| 821 | globs = frame.f_globals if frame else None |
| 822 | line = linecache.getline(filename, lineno, globs) |
| 823 | if not line: |
| 824 | self.message('End of file') |
| 825 | return 0 |
| 826 | line = line.strip() |
| 827 | # Don't allow setting breakpoint at a blank line |
| 828 | if (not line or (line[0] == '#') or |
| 829 | (line[:3] == '"""') or line[:3] == "'''"): |
| 830 | self.error('Blank or comment') |
| 831 | return 0 |
| 832 | return lineno |
| 833 | |
| 834 | def do_enable(self, arg): |
| 835 | """enable bpnumber [bpnumber ...] |