2017-04-27 14:16:57 -07:00
|
|
|
# Copyright 2017 the authors.
|
|
|
|
# This file is part of Hy, which is free software licensed under the Expat
|
|
|
|
# license. See the LICENSE.
|
2013-04-04 19:32:56 -04:00
|
|
|
|
2013-09-24 10:27:30 +03:00
|
|
|
try:
|
|
|
|
import __builtin__ as builtins
|
|
|
|
except ImportError:
|
|
|
|
import builtins # NOQA
|
2013-12-29 12:57:48 +02:00
|
|
|
try:
|
|
|
|
from py_compile import MAGIC, wr_long
|
|
|
|
except ImportError:
|
|
|
|
# py_compile.MAGIC removed and imp.get_magic() deprecated in Python 3.4
|
|
|
|
from importlib.util import MAGIC_NUMBER as MAGIC # NOQA
|
|
|
|
|
|
|
|
def wr_long(f, x):
|
|
|
|
"""Internal; write a 32-bit int to a file in little-endian order."""
|
|
|
|
f.write(bytes([x & 0xff,
|
|
|
|
(x >> 8) & 0xff,
|
|
|
|
(x >> 16) & 0xff,
|
|
|
|
(x >> 24) & 0xff]))
|
2013-04-12 20:39:45 +02:00
|
|
|
import sys
|
|
|
|
|
2013-09-29 14:53:44 +02:00
|
|
|
PY3 = sys.version_info[0] >= 3
|
2015-04-12 20:35:08 -07:00
|
|
|
PY35 = sys.version_info >= (3, 5)
|
2013-04-12 20:39:45 +02:00
|
|
|
|
2017-04-13 16:13:03 -07:00
|
|
|
str_type = str if PY3 else unicode # NOQA
|
|
|
|
bytes_type = bytes if PY3 else str # NOQA
|
|
|
|
long_type = int if PY3 else long # NOQA
|
|
|
|
string_types = str if PY3 else basestring # NOQA
|
2015-01-14 17:45:23 -05:00
|
|
|
|
2014-11-01 15:00:41 -05:00
|
|
|
if PY3:
|
|
|
|
exec('def raise_empty(t, *args): raise t(*args) from None')
|
|
|
|
else:
|
2014-11-01 16:07:39 -05:00
|
|
|
def raise_empty(t, *args):
|
|
|
|
raise t(*args)
|