Drop support for Python 2.6

This commit is contained in:
Kodi Arfer 2017-04-13 16:09:45 -07:00
parent a9cfe25068
commit ef3bad7e03
3 changed files with 27 additions and 65 deletions

View File

@ -38,7 +38,6 @@ except ImportError:
(x >> 24) & 0xff])) (x >> 24) & 0xff]))
import sys import sys
PY27 = sys.version_info >= (2, 7)
PY3 = sys.version_info[0] >= 3 PY3 = sys.version_info[0] >= 3
PY33 = sys.version_info >= (3, 3) PY33 = sys.version_info >= (3, 3)
PY34 = sys.version_info >= (3, 4) PY34 = sys.version_info >= (3, 4)

View File

@ -33,7 +33,7 @@ from hy.lex.parser import hy_symbol_mangle
import hy.macros import hy.macros
from hy._compat import ( from hy._compat import (
str_type, bytes_type, long_type, PY27, PY33, PY3, PY34, PY35, raise_empty) str_type, bytes_type, long_type, PY33, PY3, PY34, PY35, raise_empty)
from hy.macros import require, macroexpand, sharp_macroexpand from hy.macros import require, macroexpand, sharp_macroexpand
import hy.importer import hy.importer
@ -1547,53 +1547,36 @@ class HyASTCompiler(object):
@builds("set_comp") @builds("set_comp")
@checkargs(min=2, max=3) @checkargs(min=2, max=3)
def compile_set_comprehension(self, expr): def compile_set_comprehension(self, expr):
if PY27: ret = self.compile_list_comprehension(expr)
ret = self.compile_list_comprehension(expr) expr = ret.expr
expr = ret.expr ret.expr = ast.SetComp(
ret.expr = ast.SetComp( lineno=expr.lineno,
lineno=expr.lineno, col_offset=expr.col_offset,
col_offset=expr.col_offset, elt=expr.elt,
elt=expr.elt, generators=expr.generators)
generators=expr.generators)
return ret return ret
expr[0] = HySymbol("list_comp").replace(expr[0])
expr = HyExpression([HySymbol("set"), expr]).replace(expr)
return self.compile(expr)
@builds("dict_comp") @builds("dict_comp")
@checkargs(min=3, max=4) @checkargs(min=3, max=4)
def compile_dict_comprehension(self, expr): def compile_dict_comprehension(self, expr):
if PY27: expr.pop(0) # dict-comp
expr.pop(0) # dict-comp key = expr.pop(0)
key = expr.pop(0) value = expr.pop(0)
value = expr.pop(0)
gen_res, gen = self._compile_generator_iterables(expr) gen_res, gen = self._compile_generator_iterables(expr)
compiled_key = self.compile(key) compiled_key = self.compile(key)
compiled_value = self.compile(value) compiled_value = self.compile(value)
ret = compiled_key + compiled_value + gen_res ret = compiled_key + compiled_value + gen_res
ret += ast.DictComp( ret += ast.DictComp(
lineno=expr.start_line, lineno=expr.start_line,
col_offset=expr.start_column, col_offset=expr.start_column,
key=compiled_key.force_expr, key=compiled_key.force_expr,
value=compiled_value.force_expr, value=compiled_value.force_expr,
generators=gen) generators=gen)
return ret return ret
# In Python 2.6, turn (dict-comp key value [foo]) into
# (dict (list-comp (, key value) [foo]))
expr[0] = HySymbol("list_comp").replace(expr[0])
expr[1:3] = [HyExpression(
[HySymbol(",")] +
expr[1:3]
).replace(expr[1])]
expr = HyExpression([HySymbol("dict"), expr]).replace(expr)
return self.compile(expr)
@builds("genexpr") @builds("genexpr")
def compile_genexpr(self, expr): def compile_genexpr(self, expr):
@ -2284,26 +2267,10 @@ class HyASTCompiler(object):
@builds(HySet) @builds(HySet)
def compile_set(self, expression): def compile_set(self, expression):
elts, ret, _ = self._compile_collect(expression) elts, ret, _ = self._compile_collect(expression)
if PY27: ret += ast.Set(elts=elts,
ret += ast.Set(elts=elts, ctx=ast.Load(),
ctx=ast.Load(), lineno=expression.start_line,
lineno=expression.start_line, col_offset=expression.start_column)
col_offset=expression.start_column)
else:
ret += ast.Call(func=ast.Name(id='set',
ctx=ast.Load(),
lineno=expression.start_line,
col_offset=expression.start_column),
args=[
ast.List(elts=elts,
ctx=ast.Load(),
lineno=expression.start_line,
col_offset=expression.start_column)],
keywords=[],
starargs=None,
kwargs=None,
lineno=expression.start_line,
col_offset=expression.start_column)
return ret return ret
@builds("fn") @builds("fn")

View File

@ -61,9 +61,6 @@ class Install(install):
install.run(self) install.run(self)
install_requires = ['rply>=0.7.0', 'astor>=0.5', 'clint>=0.4'] install_requires = ['rply>=0.7.0', 'astor>=0.5', 'clint>=0.4']
if sys.version_info[:2] < (2, 7):
install_requires.append('argparse>=1.2.1')
install_requires.append('importlib>=1.0.2')
if os.name == 'nt': if os.name == 'nt':
install_requires.append('pyreadline>=2.1') install_requires.append('pyreadline>=2.1')
@ -106,7 +103,6 @@ setup(
"Programming Language :: Lisp", "Programming Language :: Lisp",
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 2", "Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7", "Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.3",