Remove aliases: `builtins`, `FileNotFoundError`

This commit is contained in:
Kodi Arfer 2019-05-20 16:12:00 -04:00
parent 2685b01a4b
commit ecf0352d37
6 changed files with 6 additions and 19 deletions

View File

@ -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

View File

@ -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)]

View File

@ -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')

View File

@ -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

View File

@ -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`."

View File

@ -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', '')