File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -510,6 +510,28 @@ def test_traceback_specialization_with_syntax_error(self):
510
510
)
511
511
self .assertEqual (result_lines , expected_error .splitlines ())
512
512
513
+ def test_traceback_very_long_line (self ):
514
+ source = "a" * 256
515
+ bytecode = compile (source , TESTFN , "exec" )
516
+
517
+ with open (TESTFN , "w" ) as file :
518
+ file .write (source )
519
+ self .addCleanup (unlink , TESTFN )
520
+
521
+ func = partial (exec , bytecode )
522
+ result_lines = self .get_exception (func )
523
+
524
+ lineno_f = bytecode .co_firstlineno
525
+ expected_error = (
526
+ 'Traceback (most recent call last):\n '
527
+ f' File "{ __file__ } ", line { self .callable_line } , in get_exception\n '
528
+ ' callable()\n '
529
+ ' ^^^^^^^^^^\n '
530
+ f' File "{ TESTFN } ", line { lineno_f } , in <module>\n '
531
+ f' { source } \n '
532
+ )
533
+ self .assertEqual (result_lines , expected_error .splitlines ())
534
+
513
535
def assertSpecialized (self , func , expected_specialization ):
514
536
result_lines = self .get_exception (func )
515
537
specialization_line = result_lines [- 1 ]
Original file line number Diff line number Diff line change @@ -462,7 +462,11 @@ def format_frame(self, frame):
462
462
row .append (' {}\n ' .format (frame .line .strip ()))
463
463
464
464
stripped_characters = len (frame ._original_line ) - len (frame .line .lstrip ())
465
- if frame .end_lineno == frame .lineno and frame .end_colno != 0 :
465
+ if (
466
+ frame .end_lineno == frame .lineno
467
+ and frame .colno is not None
468
+ and frame .end_colno is not None
469
+ ):
466
470
colno = _byte_offset_to_character_offset (frame ._original_line , frame .colno )
467
471
end_colno = _byte_offset_to_character_offset (frame ._original_line , frame .end_colno )
468
472
You can’t perform that action at this time.
0 commit comments