You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
raise_from does not behave exactly like raise from #141
This, of course, does not work on Python 2. Using Python 3 I get the following output:
Traceback (most recent call last):
File "pepex2.py", line 7, in __init__
self.file = open(filename)
FileNotFoundError: [Errno 2] No such file or directory: 'dne'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "pepex2.py", line 11, in <module>
fd = FileDatabase('dne')
File "pepex2.py", line 9, in __init__
raise DatabaseError('failed to open') from exc
__main__.DatabaseError: failed to open
When using raise_from for Python2 compatibility
fromfuture.utilsimportraise_from# [...]raise_from(DatabaseError('failed to open'), exc)
this output (still with Python3) changes to:
FileNotFoundError: [Errno 2] No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "pepex2.py", line 13, in <module>
fd = FileDatabase('dne')
File "pepex2.py", line 11, in __init__
raise_from(DatabaseError('failed to open'), exc)
File "/home/marc/.virtualenvs/scratch_future3/lib/python3.3/site-packages/future/utils/__init__.py", line 382, in raise_from
exec(execstr, myglobals, mylocals)
File "<string>", line 1, in <module>
__main__.DatabaseError: failed to open
Note that the traceback and exception information are missing from the FileNotFoundError.
I think we've fixed now in v0.16.0 thanks to a new raise_from implementation on Py3. Could you please give it a whirl and let me know if it all looks good to you?
My apologies, I cannot answer your questions - you see, lately have started moving away from py2/3 code towards py3-only code. The compatibility debt was too great to curry.
I'm very grateful for your efforts on this library.
Activity
ankostis commentedon Aug 27, 2015
Just confirming that ver 0.15.0 still is buggy.
And the consequences are not neglible since the root of the error is lost.
edschofield commentedon Oct 27, 2016
Thanks for the feedback, Kostis!
I think we've fixed now in v0.16.0 thanks to a new
raise_fromimplementation on Py3. Could you please give it a whirl and let me know if it all looks good to you?Update What's New doc to mention that issue #141 is fixed in v0.16.0
Update What's New doc to mention that issue #141 is fixed in v0.16.0
ankostis commentedon Feb 14, 2017
My apologies, I cannot answer your questions - you see, lately have started moving away from py2/3 code towards py3-only code. The compatibility debt was too great to curry.
I'm very grateful for your efforts on this library.
Stelminator commentedon Jun 2, 2017
I have a potentially related problem with raise_from, specifically the behavior of
__context__on python2:native python3
output:
using raise_from
python3 output:
python2 output:
so basically, the
__context__is being set when it already has been. In this case thebarexception is being set as its own__context__on python2.I think I have an appropriate fix in: Stelminator@42cee74
which is just:
Stelminator commentedon Jun 2, 2017
I suppose that's still not quite complete:
Edit: I this actually might be a bug in python3. I don't think
__context__is ever supposed to get reset toNone(unless done explicitly).Stelminator commentedon Aug 15, 2017
crosslink to my report to python bug tracker: http://bugs.python.org/issue31213
JoshRosen commentedon Aug 17, 2018
Cross-link to what looks (at first glance) to be a similar problem in
six's Python 2 version ofraise_from: benjaminp/six#193