cross py2/py3 syntax fix

This commit is contained in:
Piper Merriam 2016-12-28 16:04:40 -07:00
parent 20733c8e2b
commit d0cd50dae3
4 changed files with 8 additions and 13 deletions

View File

@ -29,4 +29,4 @@ class BadFunctionCallOutput(Exception):
"""We failed to decode ABI output.
Most likely ABI mismatch.
"""
"""

View File

@ -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

View File

@ -0,0 +1,2 @@
def raise_from(my_exception, other_exception):
raise my_exception, None, sys.exc_info()[2] # noqa [w602]

View File

@ -0,0 +1,2 @@
def raise_from(my_exception, other_exception):
raise my_exception from other_exception