b(reak) [ ([filename:]lineno | function) [, condition] ] Without argument, list all breaks. With a line number argument, set a break at this line in the current file. With a function name, set a break at the first executable line of that function. If a second argu
(self, arg, temporary=False)
| 1371 | complete_commands = _complete_bpnumber |
| 1372 | |
| 1373 | def do_break(self, arg, temporary=False): |
| 1374 | """b(reak) [ ([filename:]lineno | function) [, condition] ] |
| 1375 | |
| 1376 | Without argument, list all breaks. |
| 1377 | |
| 1378 | With a line number argument, set a break at this line in the |
| 1379 | current file. With a function name, set a break at the first |
| 1380 | executable line of that function. If a second argument is |
| 1381 | present, it is a string specifying an expression which must |
| 1382 | evaluate to true before the breakpoint is honored. |
| 1383 | |
| 1384 | The line number may be prefixed with a filename and a colon, |
| 1385 | to specify a breakpoint in another file (probably one that |
| 1386 | hasn't been loaded yet). The file is searched for on |
| 1387 | sys.path; the .py suffix may be omitted. |
| 1388 | """ |
| 1389 | if not arg: |
| 1390 | if self.breaks: # There's at least one |
| 1391 | self.message("Num Type Disp Enb Where") |
| 1392 | for bp in bdb.Breakpoint.bpbynumber: |
| 1393 | if bp: |
| 1394 | self.message(bp.bpformat()) |
| 1395 | return |
| 1396 | # parse arguments; comma has lowest precedence |
| 1397 | # and cannot occur in filename |
| 1398 | filename = None |
| 1399 | lineno = None |
| 1400 | cond = None |
| 1401 | module_globals = None |
| 1402 | comma = arg.find(',') |
| 1403 | if comma > 0: |
| 1404 | # parse stuff after comma: "condition" |
| 1405 | cond = arg[comma+1:].lstrip() |
| 1406 | if err := self._compile_error_message(cond): |
| 1407 | self.error('Invalid condition %s: %r' % (cond, err)) |
| 1408 | return |
| 1409 | arg = arg[:comma].rstrip() |
| 1410 | # parse stuff before comma: [filename:]lineno | function |
| 1411 | colon = arg.rfind(':') |
| 1412 | funcname = None |
| 1413 | if colon >= 0: |
| 1414 | filename = arg[:colon].rstrip() |
| 1415 | f = self.lookupmodule(filename) |
| 1416 | if not f: |
| 1417 | self.error('%r not found from sys.path' % filename) |
| 1418 | return |
| 1419 | else: |
| 1420 | filename = f |
| 1421 | arg = arg[colon+1:].lstrip() |
| 1422 | try: |
| 1423 | lineno = int(arg) |
| 1424 | except ValueError: |
| 1425 | self.error('Bad lineno: %s' % arg) |
| 1426 | return |
| 1427 | else: |
| 1428 | # no colon; can be lineno or function |
| 1429 | try: |
| 1430 | lineno = int(arg) |
no test coverage detected