Skip to content

Commit

Permalink
Disable Python 3's exception chaining when reraising
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschneider committed May 1, 2016
1 parent 4e575e7 commit 8c86495
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gym/utils/reraise.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys

# We keep the actual reraising in different modules since the
# Python 2 version SyntaxError's in Python 3.
# We keep the actual reraising in different modules, since the
# reraising code uses syntax mutually exclusive to Python 2/3.
if sys.version_info[0] < 3:
from .reraise_impl_py2 import reraise_impl
else:
Expand Down
4 changes: 3 additions & 1 deletion gym/utils/reraise_impl_py3.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# http://stackoverflow.com/a/33822606 -- `from None` disables Python 3'
# semi-smart exception chaining, which we don't want in this case.
def reraise_impl(e, traceback):
raise e.with_traceback(traceback)
raise e.with_traceback(traceback) from None

0 comments on commit 8c86495

Please sign in to comment.