Skip to content

Commit 6646005

Browse files
author
Dan
committed
Preserve stack trace when re-raising exceptions
1 parent aa7ff49 commit 6646005

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pssh/pssh_client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ def run_command(self, *args, **kwargs):
515515
for cmd in cmds:
516516
try:
517517
self.get_output(cmd, output)
518-
except Exception, ex:
518+
except Exception:
519519
if stop_on_errors:
520-
raise ex
520+
raise
521521
return output
522522

523523
def exec_command(self, *args, **kwargs):
@@ -600,15 +600,16 @@ def get_output(self, cmd, output):
600600
try:
601601
(channel, host, stdout, stderr, stdin) = cmd.get()
602602
except Exception, ex:
603+
exc = sys.exc_info()
603604
try:
604605
host = ex.args[1]
605-
except IndexError:
606+
except IndexError, ex:
606607
logger.error("Got exception with no host argument - "
607608
"cannot update output data with %s", ex)
608-
raise ex
609+
raise exc[1], None, exc[2]
609610
self._update_host_output(output, host, None, None, None, None, None, cmd,
610611
exception=ex)
611-
raise ex
612+
raise
612613
self._update_host_output(output, host, self._get_exit_code(channel),
613614
channel, stdout, stderr, stdin, cmd)
614615

0 commit comments

Comments
 (0)