Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise_from breaks on PY3 when the base exception has multiple arguments #235

Closed
Antar1011 opened this issue Sep 2, 2016 · 2 comments
Closed

Comments

@Antar1011
Copy link

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).

edschofield added a commit that referenced this issue Sep 22, 2016
@Daenyth
Copy link

Daenyth commented Oct 26, 2016

Dupe #234?

edschofield added a commit that referenced this issue Oct 27, 2016
edschofield added a commit that referenced this issue Oct 27, 2016
@edschofield
Copy link
Contributor

I think this is now fixed in v0.16.0. Please feel to re-open this if you notice any more problems. Thanks for reporting the bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants