Format tracebacks lines with pointing arrow, leading numbers... Parameters ========== lnum: int index: int lines: list[string] Colors: ColorScheme used. lvals: bytes Values of local variables, already colored, to inject just after the error line.
(lnum, index, lines, Colors, lvals, _line_format)
| 380 | |
| 381 | |
| 382 | def _format_traceback_lines(lnum, index, lines, Colors, lvals, _line_format): |
| 383 | """ |
| 384 | Format tracebacks lines with pointing arrow, leading numbers... |
| 385 | |
| 386 | Parameters |
| 387 | ========== |
| 388 | |
| 389 | lnum: int |
| 390 | index: int |
| 391 | lines: list[string] |
| 392 | Colors: |
| 393 | ColorScheme used. |
| 394 | lvals: bytes |
| 395 | Values of local variables, already colored, to inject just after the error line. |
| 396 | _line_format: f (str) -> (str, bool) |
| 397 | return (colorized version of str, failure to do so) |
| 398 | """ |
| 399 | numbers_width = INDENT_SIZE - 1 |
| 400 | res = [] |
| 401 | |
| 402 | for i,line in enumerate(lines, lnum-index): |
| 403 | line = py3compat.cast_unicode(line) |
| 404 | |
| 405 | new_line, err = _line_format(line, 'str') |
| 406 | if not err: |
| 407 | line = new_line |
| 408 | |
| 409 | if i == lnum: |
| 410 | # This is the line with the error |
| 411 | pad = numbers_width - len(str(i)) |
| 412 | num = '%s%s' % (debugger.make_arrow(pad), str(lnum)) |
| 413 | line = '%s%s%s %s%s' % (Colors.linenoEm, num, |
| 414 | Colors.line, line, Colors.Normal) |
| 415 | else: |
| 416 | num = '%*s' % (numbers_width, i) |
| 417 | line = '%s%s%s %s' % (Colors.lineno, num, |
| 418 | Colors.Normal, line) |
| 419 | |
| 420 | res.append(line) |
| 421 | if lvals and i == lnum: |
| 422 | res.append(lvals + '\n') |
| 423 | return res |
| 424 | |
| 425 | def is_recursion_error(etype, value, records): |
| 426 | try: |