Remove miscellaneous PY3 checks

This commit is contained in:
Kodi Arfer 2019-05-20 15:18:56 -04:00
parent bba97ab2a6
commit 2685b01a4b
3 changed files with 9 additions and 17 deletions

View File

@ -35,7 +35,7 @@ from hy.importer import runhy
from hy.completer import completion, Completer from hy.completer import completion, Completer
from hy.macros import macro, require from hy.macros import macro, require
from hy.models import HyExpression, HyString, HySymbol from hy.models import HyExpression, HyString, HySymbol
from hy._compat import builtins, PY3, FileNotFoundError from hy._compat import builtins, FileNotFoundError
sys.last_type = None sys.last_type = None
@ -661,7 +661,7 @@ def hy2py_main():
if options.with_source: if options.with_source:
# need special printing on Windows in case the # need special printing on Windows in case the
# codepage doesn't support utf-8 characters # codepage doesn't support utf-8 characters
if PY3 and platform.system() == "Windows": if platform.system() == "Windows":
for h in hst: for h in hst:
try: try:
print(h) print(h)
@ -676,7 +676,7 @@ def hy2py_main():
_ast = hy_compile(hst, '__main__', filename=filename, source=source) _ast = hy_compile(hst, '__main__', filename=filename, source=source)
if options.with_ast: if options.with_ast:
if PY3 and platform.system() == "Windows": if platform.system() == "Windows":
_print_for_windows(astor.dump_tree(_ast)) _print_for_windows(astor.dump_tree(_ast))
else: else:
print(astor.dump_tree(_ast)) print(astor.dump_tree(_ast))
@ -684,7 +684,7 @@ def hy2py_main():
print() print()
if not options.without_python: if not options.without_python:
if PY3 and platform.system() == "Windows": if platform.system() == "Windows":
_print_for_windows(astor.code_gen.to_source(_ast)) _print_for_windows(astor.code_gen.to_source(_ast))
else: else:
print(astor.code_gen.to_source(_ast)) print(astor.code_gen.to_source(_ast))

View File

@ -5,12 +5,10 @@
;;;; Hy shadow functions ;;;; Hy shadow functions
(import operator) (import operator)
(import [hy._compat [PY3]])
(require [hy.core.bootstrap [*]]) (require [hy.core.bootstrap [*]])
(if PY3 (import [functools [reduce]])
(import [functools [reduce]]))
(defn + [&rest args] (defn + [&rest args]
"Shadowed `+` operator adds `args`." "Shadowed `+` operator adds `args`."
@ -60,10 +58,9 @@
"Shadowed `%` operator takes `x` modulo `y`." "Shadowed `%` operator takes `x` modulo `y`."
(% x y)) (% x y))
(if PY3 (defn @ [a1 &rest a-rest]
(defn @ [a1 &rest a-rest] "Shadowed `@` operator matrix multiples `a1` by each `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] (defn << [a1 a2 &rest a-rest]
"Shadowed `<<` operator performs left-shift on `a1` by `a2`, ..., `a-rest`." "Shadowed `<<` operator performs left-shift on `a1` by `a2`, ..., `a-rest`."
@ -173,5 +170,3 @@
'and 'or 'not 'and 'or 'not
'is 'is-not 'in 'not-in 'is 'is-not 'in 'not-in
'get]) 'get])
(if (not PY3)
(.remove EXPORTS '@))

View File

@ -9,7 +9,7 @@ import traceback
from contextlib import contextmanager 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.models import replace_hy_obj, HyExpression, HySymbol, wrap_value
from hy.lex import mangle from hy.lex import mangle
from hy.errors import (HyLanguageError, HyMacroExpansionError, HyTypeError, from hy.errors import (HyLanguageError, HyMacroExpansionError, HyTypeError,
@ -74,9 +74,6 @@ def tag(name):
def _(fn): def _(fn):
_name = mangle('#{}'.format(name)) _name = mangle('#{}'.format(name))
if not PY3:
_name = _name.encode('UTF-8')
fn = rename_function(fn, _name) fn = rename_function(fn, _name)
module = inspect.getmodule(fn) module = inspect.getmodule(fn)