diff --git a/NEWS.rst b/NEWS.rst index 73db09390..5f83fd543 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,26 +1,27 @@ .. default-role:: code -Unreleased +0.25.0 (released 2022-11-08) ============================== -Other Breaking Changes +Breaking Changes ------------------------------ * `dfor` no longer requires brackets around its final arguments, so `(dfor x (range 5) [x (* 2 x)])` is now `(dfor x (range 5) x (* 2 x))`. - -New Features ------------------------------- -* Python 3.11 is now supported. -* `except*` (PEP 654) is now recognized in `try`. +* `except*` (PEP 654) is now recognized in `try`, and a placeholder + macro for `except*` has been added. Bug Fixes ------------------------------ -* Fixed `hy.repr` of `slice` objects with non-integer arguments. * `__file__` should now be set the same way as in Python. +* `\N{…}` escape sequences are now recognized in f-strings. * Fixed a bug with `python -O` where assertions were still partly evaluated. -* `\N{…}` escape sequences are now recognized in f-strings. +* Fixed `hy.repr` of `slice` objects with non-integer arguments. + +New Features +------------------------------ +* Python 3.11 is now supported. Misc. Improvements ------------------------------ diff --git a/docs/api.rst b/docs/api.rst index c19cc5da0..942770ad9 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1428,6 +1428,7 @@ expanded, is crash, regardless of their arguments: - ``else`` - ``except`` +- ``except*`` - ``finally`` - ``unpack-mapping`` - ``unquote`` diff --git a/hy/core/result_macros.py b/hy/core/result_macros.py index c3871139a..8d5390e45 100644 --- a/hy/core/result_macros.py +++ b/hy/core/result_macros.py @@ -1895,7 +1895,8 @@ def compile_let(compiler, expr, root, bindings, body): @pattern_macro( - "unquote unquote-splice unpack-mapping except finally else".split(), [many(FORM)] + "unquote unquote-splice unpack-mapping except except* finally else".split(), + [many(FORM)], ) def compile_placeholder(compiler, expr, root, body): raise ValueError(f"`{root}` is not allowed here") diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py index 7083be6b7..800c830c3 100644 --- a/tests/compilers/test_ast.py +++ b/tests/compilers/test_ast.py @@ -579,14 +579,22 @@ def test_setv_builtins(): ) -def test_top_level_unquote(): +def placeholder_macro(x, ename=None): with pytest.raises(HyLanguageError) as e: - can_compile("(unquote)") - assert "`unquote` is not allowed here" in e.value.msg + can_compile(f"({x})") + assert f"`{ename or x}` is not allowed here" in e.value.msg - with pytest.raises(HyLanguageError) as e: - can_compile("(unquote-splice)") - assert "`unquote-splice` is not allowed here" in e.value.msg + +def test_top_level_unquote(): + placeholder_macro("unquote") + placeholder_macro("unquote-splice") + placeholder_macro("unquote_splice", "unquote-splice") + + +def test_bad_exception(): + placeholder_macro("except") + placeholder_macro("except*") + placeholder_macro(hy.mangle("except*"), "except*") def test_lots_of_comment_lines():