Drop support for Pythons 3 older than 3.3

This commit is contained in:
Kodi Arfer 2017-04-13 16:17:32 -07:00
parent 5aaa7d92d8
commit a27d737e1c
8 changed files with 14 additions and 19 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
Changes from 0.12.1
[ Language Changes ]
* Pythons 2.6, 3.0, 3.1, and 3.2 are no longer supported
* `let` has been removed. Python's scoping rules do not make a proper
implementation of it possible. Use `setv` instead.
* `lambda` has been removed, but `fn` now does exactly what `lambda` did

View File

@ -39,7 +39,6 @@ except ImportError:
import sys
PY3 = sys.version_info[0] >= 3
PY33 = sys.version_info >= (3, 3)
PY34 = sys.version_info >= (3, 4)
PY35 = sys.version_info >= (3, 5)

View File

@ -33,7 +33,7 @@ from hy.lex.parser import hy_symbol_mangle
import hy.macros
from hy._compat import (
str_type, bytes_type, long_type, PY33, PY3, PY34, PY35, raise_empty)
str_type, bytes_type, long_type, PY3, PY34, PY35, raise_empty)
from hy.macros import require, macroexpand, sharp_macroexpand
import hy.importer
@ -861,7 +861,7 @@ class HyASTCompiler(object):
ret = handler_results
if PY33:
if PY3:
# Python 3.3 features a merge of TryExcept+TryFinally into Try.
return ret + ast.Try(
lineno=expr.start_line,
@ -1170,10 +1170,7 @@ class HyASTCompiler(object):
@checkargs(max=1)
def compile_yield_expression(self, expr):
expr.pop(0)
if PY33:
ret = Result(contains_yield=False)
else:
ret = Result(contains_yield=True)
ret = Result(contains_yield=(not PY3))
value = None
if expr != []:
@ -1190,7 +1187,7 @@ class HyASTCompiler(object):
@builds("yield_from")
@checkargs(max=1)
def compile_yield_from_expression(self, expr):
if not PY33:
if not PY3:
raise HyCompileError(
"yield-from only supported in python 3.3+!")
@ -1464,7 +1461,7 @@ class HyASTCompiler(object):
optional_vars=thing,
body=body.stmts)
if PY33:
if PY3:
the_with.items = [ast.withitem(context_expr=ctx.force_expr,
optional_vars=thing)]
@ -2367,7 +2364,7 @@ class HyASTCompiler(object):
return ret
if body.expr:
if body.contains_yield and not PY33:
if body.contains_yield and not PY3:
# Prior to PEP 380 (introduced in Python 3.3)
# generators may not have a value in a return
# statement.

View File

@ -26,8 +26,7 @@
;;; They are automatically required in every module, except inside hy.core
(import [hy.models [HyList HySymbol]]
[hy._compat [PY33 PY34]])
(import [hy.models [HyList HySymbol]])
(defmacro as-> [head name &rest rest]
"Expands to sequence of assignments to the provided name, starting with head.

View File

@ -35,7 +35,7 @@ import ast
import os
import __future__
from hy._compat import PY3, PY33, PY34, MAGIC, builtins, long_type, wr_long
from hy._compat import PY3, PY34, MAGIC, builtins, long_type, wr_long
from hy._compat import string_types
@ -218,7 +218,7 @@ def write_code_as_pyc(fname, code):
with builtins.open(cfile, 'wb') as fc:
fc.write(MAGIC)
wr_long(fc, timestamp)
if PY33:
if PY3:
wr_long(fc, st.st_size)
marshal.dump(code, fc)

View File

@ -24,7 +24,7 @@ import sys
from hy import compiler
from hy.models import HyExpression, HyList, HySymbol, HyInteger
from hy._compat import PY33
from hy._compat import PY3
if sys.version_info[0] <= 2 and sys.version_info[1] <= 6:
import unittest2 as unittest
@ -105,7 +105,7 @@ class HyASTCompilerTest(unittest.TestCase):
self.assertIsInstance(body[0], ast.Expr)
self.assertIsInstance(body[0].value, ast.Yield)
if PY33:
if PY3:
# From 3.3+, the final statement becomes a return value
self.assertIsInstance(body[1], ast.Return)
self.assertIsInstance(body[1].value, ast.BinOp)

View File

@ -5,7 +5,7 @@
[hy.errors [HyTypeError]])
(import sys)
(import [hy._compat [PY33 PY34 PY35]])
(import [hy._compat [PY3 PY34 PY35]])
(defn test-sys-argv []
"NATIVE: test sys.argv"
@ -649,7 +649,7 @@
(defn test-yield-with-return []
"NATIVE: test yield with return"
(defn gen [] (yield 3) "goodbye")
(if PY33
(if PY3
(do (setv gg (gen))
(assert (= 3 (next gg)))
(try (next gg)

View File

@ -1,7 +1,6 @@
;; Tests where the emitted code relies on Python 3.
;; Conditionally included in nosetests runs.
(import [hy._compat [PY33]])
(import [hy.errors [HyCompileError]])