]> arthur.barton.de Git - bup.git/commit
Add compat.reraise to handle python 3 syntax breakage
authorRob Browning <rlb@defaultvalue.org>
Sat, 28 Dec 2019 20:39:44 +0000 (14:39 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sun, 19 Jan 2020 17:46:10 +0000 (11:46 -0600)
commit20dc106a111db4822ccac34688fa8eb5ae2bfc48
tree7918a649b589ed702b9ec0f3d240e602f3360fd6
parent78c8cdfb919b2688a005e76aae8d030086fc40fd
Add compat.reraise to handle python 3 syntax breakage

Add a exception reraise function to compat that will allow us to
rewrite invocations like this:

    except Exception as e:
        raise ClientError, e, sys.exc_info()[2]

as this:

    except Exception as e:
        reraise(ClientError(e))

since python 3 now provides a with_traceback() method that we can (and
must) use instead.

Put the python 2 specific formulation (shown above) in a separate
py2raise module that we can conditionally import because python 3
decided to make the python 2 code produce a syntax error.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/compat.py
lib/bup/py2raise.py [new file with mode: 0644]