Skip to content

Commit e60ddfe

Browse files
author
y-p
committed
DOC/BLD: ipython_directive cleanups
1 parent fe8fe38 commit e60ddfe

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

doc/sphinxext/ipython_directive.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,15 +447,11 @@ def process_input(self, data, input_prompt, lineno):
447447
# context information
448448
filename = self.state.document.current_source
449449
lineno = self.state.document.current_line
450-
try:
451-
lineno -= 1
452-
except:
453-
pass
454450

455451
# output any exceptions raised during execution to stdout
456452
# unless :okexcept: has been specified.
457453
if not is_okexcept and "Traceback" in output:
458-
s = "\nException in %s at line %s:\n" % (filename, lineno)
454+
s = "\nException in %s at block ending on line %s\n" % (filename, lineno)
459455
sys.stdout.write('\n\n>>>'+'-'*73)
460456
sys.stdout.write(s)
461457
sys.stdout.write(output)
@@ -464,15 +460,16 @@ def process_input(self, data, input_prompt, lineno):
464460
# output any warning raised during execution to stdout
465461
# unless :okwarning: has been specified.
466462
if not is_okwarning:
463+
import textwrap
467464
for w in ws:
468-
s = "\nWarning raised in %s at line %s:\n" % (filename, lineno)
465+
s = "\nWarning in %s at block ending on line %s\n" % (filename, lineno)
469466
sys.stdout.write('\n\n>>>'+'-'*73)
470467
sys.stdout.write(s)
471468
sys.stdout.write('-'*76+'\n')
472469
s=warnings.formatwarning(w.message, w.category,
473470
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')
476473

477474
self.cout.truncate(0)
478475
return (ret, input_lines, output, is_doctest, decorator, image_file,

0 commit comments

Comments
 (0)