Source entered interactively can now be displayed in traceback output. Also,
the REPL object is now available in its namespace, so that, for instance,
display options--like `spy`--can be turned on and off interactively.
Closeshylang/hy#1397.
Compiler and command-line error messages now reflect their Python counterparts.
E.g. where Python emits a `SyntaxError`, so does Hy; same for `TypeError`s.
Multiple tests have been added that check the format and type of raised
exceptions over varying command-line invocations (e.g. interactive and not).
A new exception type for `require` errors was added so that they can be treated
like normal run-time errors and not compiler errors.
The Hy REPL has been further refactored to better match the class-structured
API. Now, different error types are handled separately and leverage more base
class-provided functionality.
Closeshylang/hy#1486.
Colored exception output is now disabled by default and configurable through
`hy.errors._hy_colored_errors` and the environment variable
`HY_COLORED_ERRORS`.
Likewise, Hy model/AST color printing is now configurable and disabled by
default. The corresponding variables are `hy.models._hy_colored_ast_objects`
and `HY_COLORED_AST_OBJECTS`.
Closeshylang/hy#1429, closeshylang/hy#1510.
These changes make the Hy REPL more closely follow `code.InteractiveConsole`'s
class interface and provide minimally intrusive traceback print-out filtering
via a context manager that temporarily alters `sys.excepthook`. In other words,
exception messages from the REPL will no longer show Hy internal
code (e.g. importer, compiler and parsing functions).
The boolean variable `hy.errors._hy_filter_internal_errors` dynamically
enables/disables trace filtering, and the env variable
`HY_FILTER_INTERNAL_ERRORS` can be used as the initial value.
This commit refactors the exception/error classes and their handling.
It also retains Hy source strings and their originating file information, when
available, all throughout the core parser and compiler functions.
As well, with these changes, calling code is no longer responsible for providing
source and file details to exceptions,
Closeshylang/hy#657.
These changes make `HyREPL` use a single `HyASTCompiler` instance, instead of
creating one every time a valid source string is processed.
This change avoids the unnecessary re-initiation of the standard library
`import` and `require` steps that currently occur within the module tracked by a
`HyREPL` instance.
Also, one can now pass an existing compiler instance to `hy_repl` and
`hy_compiler`.
Closeshylang/hy#1698.
Previously, when importing `hy` (and any of its sub-packages/modules), Hy source
compilation for `hy.core.language` was necessarily triggered. This, in turn,
would trigger compilation of the other standard library source files.
This commit removes that chain of events and allows the `hy` package to be
imported without any Hy compilation.
Furthermore, `read` and `read_str` are now implemented in Python and the Hy
standard library files now handle their own dependencies explicitly (i.e. they
`import` and/or `require` the other standard library files upon which they
depend).
The latter changes were necessary, because the automatically triggered
compilation of `hy.core.language` (and associated standard library files) was
serving--implicitly--as a means of producing bytecode in an order that just
happened to work for any compilation occurring afterward. This chain of
events/dependencies was extremely cryptic, brittle, and difficult to debug, and
these changes should help to remedy that.
Closeshylang/hy#1697.
Functions and variables relating to compilation and parsing have been moved to
`compiler.py` and `lex/__init__.py`, respectively. Those functions are
- `hy_parse` from `hy.importer` to `hy.lex`
- `hy_eval`, `ast_compile`, and `calling_module` from `hy.importer` to
`hy.compiler`
Closeshylang/hy#1695.