Skip to content

Commit d789837

Browse files
committed
Add fix for issues #235 and (probably) #213
1 parent 25a86fe commit d789837

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/future/utils/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,14 @@ def raise_from(exc, cause):
387387
388388
on Python 3. (See PEP 3134).
389389
"""
390-
# Is either arg an exception class (e.g. IndexError) rather than
391-
# instance (e.g. IndexError('my message here')? If so, pass the
392-
# name of the class undisturbed through to "raise ... from ...".
393-
if isinstance(exc, type) and issubclass(exc, Exception):
394-
exc = exc.__name__
395-
if isinstance(cause, type) and issubclass(cause, Exception):
396-
cause = cause.__name__
397-
execstr = "raise " + _repr_strip(exc) + " from " + _repr_strip(cause)
398390
myglobals, mylocals = _get_caller_globals_and_locals()
391+
392+
# We pass the exception and cause along with other globals
393+
# when we exec():
394+
myglobals = myglobals.copy()
395+
myglobals['__python_future_raise_from_exc'] = exc
396+
myglobals['__python_future_raise_from_cause'] = cause
397+
execstr = "raise __python_future_raise_from_exc from __python_future_raise_from_cause"
399398
exec(execstr, myglobals, mylocals)
400399

401400
def raise_(tp, value=None, tb=None):

0 commit comments

Comments
 (0)