From 2685b01a4b6e00901d6d5ea0877809abaef4be1d Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Mon, 20 May 2019 15:18:56 -0400 Subject: [PATCH] Remove miscellaneous PY3 checks --- hy/cmdline.py | 8 ++++---- hy/core/shadow.hy | 13 ++++--------- hy/macros.py | 5 +---- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/hy/cmdline.py b/hy/cmdline.py index d38ec08..e6d3a71 100644 --- a/hy/cmdline.py +++ b/hy/cmdline.py @@ -35,7 +35,7 @@ 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, PY3, FileNotFoundError +from hy._compat import builtins, FileNotFoundError sys.last_type = None @@ -661,7 +661,7 @@ def hy2py_main(): if options.with_source: # need special printing on Windows in case the # codepage doesn't support utf-8 characters - if PY3 and platform.system() == "Windows": + if platform.system() == "Windows": for h in hst: try: print(h) @@ -676,7 +676,7 @@ def hy2py_main(): _ast = hy_compile(hst, '__main__', filename=filename, source=source) if options.with_ast: - if PY3 and platform.system() == "Windows": + if platform.system() == "Windows": _print_for_windows(astor.dump_tree(_ast)) else: print(astor.dump_tree(_ast)) @@ -684,7 +684,7 @@ def hy2py_main(): print() if not options.without_python: - if PY3 and platform.system() == "Windows": + if platform.system() == "Windows": _print_for_windows(astor.code_gen.to_source(_ast)) else: print(astor.code_gen.to_source(_ast)) diff --git a/hy/core/shadow.hy b/hy/core/shadow.hy index 2135400..8a18c60 100644 --- a/hy/core/shadow.hy +++ b/hy/core/shadow.hy @@ -5,12 +5,10 @@ ;;;; Hy shadow functions (import operator) -(import [hy._compat [PY3]]) (require [hy.core.bootstrap [*]]) -(if PY3 - (import [functools [reduce]])) +(import [functools [reduce]]) (defn + [&rest args] "Shadowed `+` operator adds `args`." @@ -60,10 +58,9 @@ "Shadowed `%` operator takes `x` modulo `y`." (% x y)) -(if PY3 - (defn @ [a1 &rest a-rest] - "Shadowed `@` operator matrix multiples `a1` by each `a-rest`." - (reduce operator.matmul a-rest a1))) +(defn @ [a1 &rest a-rest] + "Shadowed `@` operator matrix multiples `a1` by each `a-rest`." + (reduce operator.matmul a-rest a1))) (defn << [a1 a2 &rest a-rest] "Shadowed `<<` operator performs left-shift on `a1` by `a2`, ..., `a-rest`." @@ -173,5 +170,3 @@ 'and 'or 'not 'is 'is-not 'in 'not-in 'get]) -(if (not PY3) - (.remove EXPORTS '@)) diff --git a/hy/macros.py b/hy/macros.py index 97d0976..32658d6 100644 --- a/hy/macros.py +++ b/hy/macros.py @@ -9,7 +9,7 @@ import traceback from contextlib import contextmanager -from hy._compat import PY3, reraise, rename_function +from hy._compat import reraise, rename_function from hy.models import replace_hy_obj, HyExpression, HySymbol, wrap_value from hy.lex import mangle from hy.errors import (HyLanguageError, HyMacroExpansionError, HyTypeError, @@ -74,9 +74,6 @@ def tag(name): def _(fn): _name = mangle('#{}'.format(name)) - if not PY3: - _name = _name.encode('UTF-8') - fn = rename_function(fn, _name) module = inspect.getmodule(fn)