From 026c8fd0939ddfad864400c935a35d808d5654f5 Mon Sep 17 00:00:00 2001 From: meejah Date: Sun, 14 Aug 2016 16:50:29 -0600 Subject: [PATCH] Print proper tracebacks when inlineCallbacks + yield involved --- src/wormhole/cli/cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wormhole/cli/cli.py b/src/wormhole/cli/cli.py index dd0c010..8e48bbd 100644 --- a/src/wormhole/cli/cli.py +++ b/src/wormhole/cli/cli.py @@ -3,7 +3,7 @@ from __future__ import print_function import os import time start = time.time() -import traceback +from os.path import expanduser, exists from textwrap import fill, dedent from sys import stdout, stderr from . import public_relay @@ -11,6 +11,7 @@ from .. import __version__ from ..timing import DebugTiming from ..errors import WrongPasswordError, WelcomeError, KeyFormatError from twisted.internet.defer import inlineCallbacks, maybeDeferred +from twisted.python.failure import Failure from twisted.internet.task import react import click @@ -111,7 +112,10 @@ def _dispatch_command(reactor, cfg, command): msg = fill("ERROR: " + dedent(e.__doc__)) print(msg, file=stderr) except Exception as e: - traceback.print_exc() + # this prints a proper traceback, whereas + # traceback.print_exc() just prints a TB to the "yield" + # line above ... + Failure().printTraceback(file=stderr) print("ERROR:", e, file=stderr) raise SystemExit(1)