File tree 1 file changed +7
-8
lines changed
1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -387,15 +387,14 @@ def raise_from(exc, cause):
387
387
388
388
on Python 3. (See PEP 3134).
389
389
"""
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 )
398
390
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"
399
398
exec (execstr , myglobals , mylocals )
400
399
401
400
def raise_ (tp , value = None , tb = None ):
You can’t perform that action at this time.
0 commit comments