python interface: make rethrow Python 3 compatible
The original approach works fine with Python 2.7 but not with Python 3.
Python 3 will give "TypeError: exceptions must derive from BaseException"
when using the original approach throwing tuples.
Instead, store the caught exceptions and rethrow them.
This works not only in Python 3, but also in Python 2.7 and Python 2.6.
An additional advantage is that traceback information is preserved
in the exception object when using Python 3.
An alternative approach would be to use "nonlocal"
to store exceptions into the outer scope, but this would
not work in Python 2.
Even though Python 2 is no longer supported
by the Python Software Foundation, it is still better
to try and preserve compatibility with Python 2.
Signed-off-by: Chielo Newctle <ChieloNewctle@Yandex.com>
Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>