diff --git a/hy/_compat.py b/hy/_compat.py index 0da0b09..65be73c 100644 --- a/hy/_compat.py +++ b/hy/_compat.py @@ -2,10 +2,6 @@ # This file is part of Hy, which is free software licensed under the Expat # license. See the LICENSE. -try: - import __builtin__ as builtins -except ImportError: - import builtins # NOQA import sys, keyword, textwrap PY3 = sys.version_info[0] >= 3 @@ -97,8 +93,3 @@ def isidentifier(x): # https://bugs.python.org/issue33899 tokens = [t for t in tokens if t[0] != T.NEWLINE] return len(tokens) == 2 and tokens[0][0] == T.NAME - -try: - FileNotFoundError = FileNotFoundError -except NameError: - FileNotFoundError = IOError diff --git a/hy/cmdline.py b/hy/cmdline.py index e6d3a71..4c0c1fa 100644 --- a/hy/cmdline.py +++ b/hy/cmdline.py @@ -19,6 +19,7 @@ import time import linecache import hashlib import codeop +import builtins import astor.code_gen @@ -35,7 +36,6 @@ from hy.importer import runhy from hy.completer import completion, Completer from hy.macros import macro, require from hy.models import HyExpression, HyString, HySymbol -from hy._compat import builtins, FileNotFoundError sys.last_type = None @@ -256,7 +256,7 @@ class HyREPL(code.InteractiveConsole, object): module, f = '.'.join(parts[:-1]), parts[-1] self.output_fn = getattr(importlib.import_module(module), f) else: - self.output_fn = __builtins__[mangle(output_fn)] + self.output_fn = getattr(builtins, mangle(output_fn)) # Pre-mangle symbols for repl recent results: *1, *2, *3 self._repl_results_symbols = [mangle("*{}".format(i + 1)) for i in range(3)] diff --git a/hy/compiler.py b/hy/compiler.py index b1d6e2d..3b0d700 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -28,15 +28,12 @@ import types import ast import sys import copy +import builtins import __future__ from collections import defaultdict from functools import reduce -if PY3: - import builtins -else: - import __builtin__ as builtins Inf = float('inf') diff --git a/hy/completer.py b/hy/completer.py index 0f65ae6..b1969c1 100644 --- a/hy/completer.py +++ b/hy/completer.py @@ -6,10 +6,10 @@ import contextlib import os import re import sys +import builtins import hy.macros import hy.compiler -from hy._compat import builtins docomplete = True diff --git a/hy/core/shadow.hy b/hy/core/shadow.hy index 8a18c60..74ab08f 100644 --- a/hy/core/shadow.hy +++ b/hy/core/shadow.hy @@ -60,7 +60,7 @@ (defn @ [a1 &rest a-rest] "Shadowed `@` operator matrix multiples `a1` by each `a-rest`." - (reduce operator.matmul a-rest a1))) + (reduce operator.matmul a-rest a1)) (defn << [a1 a2 &rest a-rest] "Shadowed `<<` operator performs left-shift on `a1` by `a2`, ..., `a-rest`." diff --git a/tests/test_bin.py b/tests/test_bin.py index 1cfb3e5..297eade 100644 --- a/tests/test_bin.py +++ b/tests/test_bin.py @@ -8,13 +8,12 @@ import os import re import shlex import subprocess +import builtins from hy.importer import cache_from_source import pytest -from hy._compat import builtins - hy_dir = os.environ.get('HY_DIR', '')