Cleanup use of PY3* in the compiler.
This commit is contained in:
parent
c5c36e1022
commit
de31aea5d2
@ -40,6 +40,7 @@ import sys
|
||||
|
||||
PY3 = sys.version_info[0] >= 3
|
||||
PY33 = sys.version_info >= (3, 3)
|
||||
PY34 = sys.version_info >= (3, 4)
|
||||
|
||||
if PY3:
|
||||
str_type = str
|
||||
|
@ -39,7 +39,7 @@ from hy.errors import HyCompileError, HyTypeError
|
||||
|
||||
import hy.macros
|
||||
from hy.macros import require, macroexpand
|
||||
from hy._compat import str_type, long_type
|
||||
from hy._compat import str_type, long_type, PY33, PY3, PY34
|
||||
import hy.importer
|
||||
|
||||
import traceback
|
||||
@ -77,7 +77,7 @@ _compile_table = {}
|
||||
|
||||
|
||||
def ast_str(foobar):
|
||||
if sys.version_info[0] >= 3:
|
||||
if PY3:
|
||||
return str(foobar)
|
||||
|
||||
try:
|
||||
@ -754,7 +754,7 @@ class HyASTCompiler(object):
|
||||
|
||||
ret = handler_results
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
if PY33:
|
||||
# Python 3.3 features a merge of TryExcept+TryFinally into Try.
|
||||
return ret + ast.Try(
|
||||
lineno=expr.start_line,
|
||||
@ -831,7 +831,7 @@ class HyASTCompiler(object):
|
||||
exceptions,
|
||||
"Exception storage target name must be a symbol.")
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
if PY3:
|
||||
# Python3 features a change where the Exception handler
|
||||
# moved the name from a Name() to a pure Python String type.
|
||||
#
|
||||
@ -1199,7 +1199,7 @@ class HyASTCompiler(object):
|
||||
optional_vars=thing,
|
||||
body=body.stmts)
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
if PY33:
|
||||
the_with.items = [ast.withitem(context_expr=ctx.force_expr,
|
||||
optional_vars=thing)]
|
||||
|
||||
@ -1699,7 +1699,7 @@ class HyASTCompiler(object):
|
||||
arglist = expression.pop(0)
|
||||
ret, args, defaults, stararg, kwargs = self._parse_lambda_list(arglist)
|
||||
|
||||
if sys.version_info >= (3, 4):
|
||||
if PY34:
|
||||
# Python 3.4+ requres that args are an ast.arg object, rather
|
||||
# than an ast.Name or bare string.
|
||||
args = [ast.arg(arg=ast_str(x),
|
||||
|
Loading…
x
Reference in New Issue
Block a user