mirror of
https://github.com/FlipsideCrypto/web3.py.git
synced 2026-02-06 10:56:47 +00:00
cross py2/py3 syntax fix
This commit is contained in:
parent
20733c8e2b
commit
d0cd50dae3
@ -29,4 +29,4 @@ class BadFunctionCallOutput(Exception):
|
||||
"""We failed to decode ABI output.
|
||||
|
||||
Most likely ABI mismatch.
|
||||
"""
|
||||
"""
|
||||
|
||||
@ -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
|
||||
from .exception_py3 import raise_from
|
||||
|
||||
2
web3/utils/exception_py2.py
Normal file
2
web3/utils/exception_py2.py
Normal file
@ -0,0 +1,2 @@
|
||||
def raise_from(my_exception, other_exception):
|
||||
raise my_exception, None, sys.exc_info()[2] # noqa [w602]
|
||||
2
web3/utils/exception_py3.py
Normal file
2
web3/utils/exception_py3.py
Normal file
@ -0,0 +1,2 @@
|
||||
def raise_from(my_exception, other_exception):
|
||||
raise my_exception from other_exception
|
||||
Loading…
Reference in New Issue
Block a user