@@ -447,15 +447,11 @@ def process_input(self, data, input_prompt, lineno):
447
447
# context information
448
448
filename = self .state .document .current_source
449
449
lineno = self .state .document .current_line
450
- try :
451
- lineno -= 1
452
- except :
453
- pass
454
450
455
451
# output any exceptions raised during execution to stdout
456
452
# unless :okexcept: has been specified.
457
453
if not is_okexcept and "Traceback" in output :
458
- s = "\n Exception in %s at line %s: \n " % (filename , lineno )
454
+ s = "\n Exception in %s at block ending on line %s\n " % (filename , lineno )
459
455
sys .stdout .write ('\n \n >>>' + '-' * 73 )
460
456
sys .stdout .write (s )
461
457
sys .stdout .write (output )
@@ -464,15 +460,16 @@ def process_input(self, data, input_prompt, lineno):
464
460
# output any warning raised during execution to stdout
465
461
# unless :okwarning: has been specified.
466
462
if not is_okwarning :
463
+ import textwrap
467
464
for w in ws :
468
- s = "\n Warning raised in %s at line %s: \n " % (filename , lineno )
465
+ s = "\n Warning in %s at block ending on line %s\n " % (filename , lineno )
469
466
sys .stdout .write ('\n \n >>>' + '-' * 73 )
470
467
sys .stdout .write (s )
471
468
sys .stdout .write ('-' * 76 + '\n ' )
472
469
s = warnings .formatwarning (w .message , w .category ,
473
470
w .filename , w .lineno , w .line )
474
- sys .stdout .write (s )
475
- sys .stdout .write ('\n <<<' + '-' * 73 + '\n \n ' )
471
+ sys .stdout .write (' \n ' . join ( textwrap . wrap ( s , 80 )) )
472
+ sys .stdout .write ('\n <<<' + '-' * 73 + '\n ' )
476
473
477
474
self .cout .truncate (0 )
478
475
return (ret , input_lines , output , is_doctest , decorator , image_file ,
0 commit comments