]> arthur.barton.de Git - bup.git/commitdiff
add_ex_tb: return the exception
authorRob Browning <rlb@defaultvalue.org>
Sun, 31 Dec 2017 18:15:40 +0000 (12:15 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sun, 31 Dec 2017 18:18:10 +0000 (12:18 -0600)
Allows:

  chain_ex(add_ex_tb(ex2), ex)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/compat.py

index 7e362095d9fe8e63bbe48e1111062ab07ca7940f..707ccbafea529cb8dfeaf5de0195306929b32913 100644 (file)
@@ -11,7 +11,8 @@ if py3:
     str_type = str
 
     def add_ex_tb(ex):
-        pass
+        """Do nothing (already handled by Python 3 infrastructure)."""
+        return ex
 
     def chain_ex(ex, context_ex):
         return ex
@@ -21,8 +22,12 @@ else:  # Python 2
     str_type = basestring
 
     def add_ex_tb(ex):
+        """Add a traceback to ex if it doesn't already have one.  Return ex.
+
+        """
         if not getattr(ex, '__traceback__', None):
             ex.__traceback__ = sys.exc_info()[2]
+        return ex
 
     def chain_ex(ex, context_ex):
         if context_ex: