From a27d737e1c6273dcb4c377d123392fc1951b3150 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Thu, 13 Apr 2017 16:17:32 -0700 Subject: [PATCH] Drop support for Pythons 3 older than 3.3 --- NEWS | 1 + hy/_compat.py | 1 - hy/compiler.py | 15 ++++++--------- hy/core/macros.hy | 3 +-- hy/importer.py | 4 ++-- tests/compilers/test_compiler.py | 4 ++-- tests/native_tests/language.hy | 4 ++-- tests/native_tests/py3_only_tests.hy | 1 - 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/NEWS b/NEWS index d38f1e7..ed448ec 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/hy/_compat.py b/hy/_compat.py index 7878d03..217bf2e 100644 --- a/hy/_compat.py +++ b/hy/_compat.py @@ -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) diff --git a/hy/compiler.py b/hy/compiler.py index ca33010..130d3f3 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -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. diff --git a/hy/core/macros.hy b/hy/core/macros.hy index 7f6f4ba..7416753 100644 --- a/hy/core/macros.hy +++ b/hy/core/macros.hy @@ -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. diff --git a/hy/importer.py b/hy/importer.py index bf71169..1db67e3 100644 --- a/hy/importer.py +++ b/hy/importer.py @@ -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) diff --git a/tests/compilers/test_compiler.py b/tests/compilers/test_compiler.py index 8c3fe93..3f1b397 100644 --- a/tests/compilers/test_compiler.py +++ b/tests/compilers/test_compiler.py @@ -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) diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 7b11edb..704bd5d 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -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) diff --git a/tests/native_tests/py3_only_tests.hy b/tests/native_tests/py3_only_tests.hy index 30044b1..6c577b4 100644 --- a/tests/native_tests/py3_only_tests.hy +++ b/tests/native_tests/py3_only_tests.hy @@ -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]])