diff --git a/web3/exceptions.py b/web3/exceptions.py index b74f789..e5b26cd 100644 --- a/web3/exceptions.py +++ b/web3/exceptions.py @@ -29,4 +29,4 @@ class BadFunctionCallOutput(Exception): """We failed to decode ABI output. Most likely ABI mismatch. - """ \ No newline at end of file + """ diff --git a/web3/utils/exception.py b/web3/utils/exception.py index 3ab2160..6020605 100644 --- a/web3/utils/exception.py +++ b/web3/utils/exception.py @@ -1,16 +1,7 @@ import sys # raise MyException() from original_exception compatibility -if sys.version_info.major == 3: - - def raise_from(my_exception, other_exception): - raise my_exception from other_exception +if sys.version_info.major == 2: + from .exception_py2 import raise_from else: - - def raise_from(my_exception, other_exception): - # This syntax is not accepted under Python 3 - # raise my_exception, None, sys.exc_info()[2] - - # For now, just swallow the original exception under Python 2. - # For better error messages please upgrade to Python 3. - raise my_exception \ No newline at end of file + from .exception_py3 import raise_from diff --git a/web3/utils/exception_py2.py b/web3/utils/exception_py2.py new file mode 100644 index 0000000..0453fc8 --- /dev/null +++ b/web3/utils/exception_py2.py @@ -0,0 +1,2 @@ +def raise_from(my_exception, other_exception): + raise my_exception, None, sys.exc_info()[2] # noqa [w602] diff --git a/web3/utils/exception_py3.py b/web3/utils/exception_py3.py new file mode 100644 index 0000000..cedbed3 --- /dev/null +++ b/web3/utils/exception_py3.py @@ -0,0 +1,2 @@ +def raise_from(my_exception, other_exception): + raise my_exception from other_exception