Skip to content

Commit c9ad56d

Browse files
committed
more undo
1 parent 98b4593 commit c9ad56d

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

Doc/library/traceback.rst

+29-29
Original file line numberDiff line numberDiff line change
@@ -589,18 +589,18 @@ module. ::
589589
import sys, traceback
590590

591591
def run_user_code(envdir):
592-
source = input(">>> ")
593-
try:
594-
exec(source, envdir)
595-
except Exception:
596-
print("Exception in user code:")
597-
print("-"*60)
598-
traceback.print_exc(file=sys.stdout)
599-
print("-"*60)
592+
source = input(">>> ")
593+
try:
594+
exec(source, envdir)
595+
except Exception:
596+
print("Exception in user code:")
597+
print("-"*60)
598+
traceback.print_exc(file=sys.stdout)
599+
print("-"*60)
600600

601601
envdir = {}
602602
while True:
603-
run_user_code(envdir)
603+
run_user_code(envdir)
604604

605605

606606
The following example demonstrates the different ways to print and format the
@@ -611,31 +611,31 @@ exception and traceback:
611611
import sys, traceback
612612

613613
def lumberjack():
614-
bright_side_of_life()
614+
bright_side_of_life()
615615

616616
def bright_side_of_life():
617-
return tuple()[0]
617+
return tuple()[0]
618618

619619
try:
620-
lumberjack()
620+
lumberjack()
621621
except IndexError as exc:
622-
print("*** print_tb:")
623-
traceback.print_tb(exc.__traceback__, limit=1, file=sys.stdout)
624-
print("*** print_exception:")
625-
traceback.print_exception(exc, limit=2, file=sys.stdout)
626-
print("*** print_exc:")
627-
traceback.print_exc(limit=2, file=sys.stdout)
628-
print("*** format_exc, first and last line:")
629-
formatted_lines = traceback.format_exc().splitlines()
630-
print(formatted_lines[0])
631-
print(formatted_lines[-1])
632-
print("*** format_exception:")
633-
print(repr(traceback.format_exception(exc)))
634-
print("*** extract_tb:")
635-
print(repr(traceback.extract_tb(exc.__traceback__)))
636-
print("*** format_tb:")
637-
print(repr(traceback.format_tb(exc.__traceback__)))
638-
print("*** tb_lineno:", exc.__traceback__.tb_lineno)
622+
print("*** print_tb:")
623+
traceback.print_tb(exc.__traceback__, limit=1, file=sys.stdout)
624+
print("*** print_exception:")
625+
traceback.print_exception(exc, limit=2, file=sys.stdout)
626+
print("*** print_exc:")
627+
traceback.print_exc(limit=2, file=sys.stdout)
628+
print("*** format_exc, first and last line:")
629+
formatted_lines = traceback.format_exc().splitlines()
630+
print(formatted_lines[0])
631+
print(formatted_lines[-1])
632+
print("*** format_exception:")
633+
print(repr(traceback.format_exception(exc)))
634+
print("*** extract_tb:")
635+
print(repr(traceback.extract_tb(exc.__traceback__)))
636+
print("*** format_tb:")
637+
print(repr(traceback.format_tb(exc.__traceback__)))
638+
print("*** tb_lineno:", exc.__traceback__.tb_lineno)
639639

640640
The output for the example would look similar to this:
641641

0 commit comments

Comments
 (0)