Closed
Description
Consider the following code:
from future.utils import raise_from
class MyException(Exception):
def __init__(self, a, b):
super(MyException, self).__init__('{0}: {1}'.format(a,7))
def foo():
raise MyException(3, 7)
def bar():
try:
foo()
except Exception as err:
raise_from(ValueError('blue'), err)
Calling bar()
works fine on PY2, but on PY3, one gets:
Traceback (most recent call last):
File "blah.py", line 15, in bar
foo()
File "blah.py", line 10, in foo
raise MyException(3, 7)
__main__.MyException: 3: 7
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "blah.py", line 27, in <module>
bar()
File "blah.py", line 17, in bar
raise_from(ValueError('blue'), err)
File "/Users/antar/Programming/.miniconda3/envs/futuristic/lib/python3.5/site-packages/future/utils/__init__.py", line 399, in raise_from
exec(execstr, myglobals, mylocals)
File "<string>", line 1, in <module>
TypeError: __init__() missing 1 required positional argument: 'b'
Basically, it looks like when future tries to re-create the exception, all it can do is parse the arguments as a single string (similar issue to #213).
Metadata
Metadata
Assignees
Labels
No labels