Adds compatibility `raise_with_traceback` method to support different `raise` syntax
Unfortunately the Python 2 `raise` syntax is not supported in Python 3.3 and not all 3.4.x versions so we deal with that by using conditional imports and a compatibility layer.pull/64/head
parent
3ac56329e2
commit
ce7ca26835
@ -0,0 +1,6 @@
|
||||
"""
|
||||
This module contains compatibility helpers for Python 2/3 interoperability.
|
||||
|
||||
It mainly exists because their are certain incompatibilities in the Python
|
||||
syntax that can only be solved by conditionally importing different functions.
|
||||
"""
|
@ -0,0 +1,6 @@
|
||||
def raise_with_traceback(exc_type, traceback, *args, **kwargs):
|
||||
"""
|
||||
Raise a new exception of type `exc_type` with an existing `traceback`. All
|
||||
additional (keyword-)arguments are forwarded to `exc_type`
|
||||
"""
|
||||
raise exc_type(*args, **kwargs).with_traceback(traceback)
|
@ -0,0 +1,6 @@
|
||||
def raise_with_traceback(exc_type, traceback, *args, **kwargs):
|
||||
"""
|
||||
Raise a new exception of type `exc_type` with an existing `traceback`. All
|
||||
additional (keyword-)arguments are forwarded to `exc_type`
|
||||
"""
|
||||
raise exc_type(*args, **kwargs), None, traceback
|
Loading…
Reference in New Issue