-
-
Notifications
You must be signed in to change notification settings - Fork 247
Expand file tree
/
Copy pathcompat.py
More file actions
33 lines (27 loc) · 792 Bytes
/
compat.py
File metadata and controls
33 lines (27 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
PY2 = sys.version_info[0] < 3
PY3 = sys.version_info[0] >= 3
PYXY = tuple(sys.version_info[:2])
if PY3:
import builtins
exec_ = getattr(builtins, "exec")
del builtins
else:
def exec_(_code_, _globs_=None, _locs_=None):
"""Execute code in a namespace."""
if _globs_ is None:
frame = sys._getframe(1)
_globs_ = frame.f_globals
if _locs_ is None:
_locs_ = frame.f_locals
del frame
elif _locs_ is None:
_locs_ = _globs_
exec("""exec _code_ in _globs_, _locs_""")
exec_("""def reraise(tp, value, tb=None):
raise tp, value, tb
""")
try:
from inspect import getfullargspec
except ImportError:
from inspect import getargspec as getfullargspec