To allow classes to have methods that match built-in names, yet, still
disallow them outside of defclass, keep an internal state whether
builtins are allowed in the current context.
By default, this is false. But defclass will set it to True when it
compiles its body, and set it back to the previous value when it's done
with that. We need to set back to the previous value to allow nested
defclasses to work properly.
This closes#783.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Strip the \ufdd0 prefix from the keyword argument before turning it into
a string: the same representation the user entered looks better, and is
printable too, thus Python2 doesn't choke on it.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Some valid-looking list comprehensions, such as (genexpr x []) can crash
Python 2.7. The AST we generate from these cannot be expressed in
Python, but were valid in Hy.
Added two guards to guard against this, so we raise an error instead of
crashing Python.
Closes#572, #591 and #634.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Postfixing functions with a bang, like set!, get!, etc are relatively
common. However, those names are not valid in python, so in the name of
python interoperability, lets mangle them to set_bang and get_bang,
respectively.
Closes#536.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
When trying to setv a callable, raise an error instead of showing the
user an incredibly ugly backtrace. Closes#532.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Closes#869. Compared to the original pull request, an issue with a
corner case was fixed, and the branch rebased on top of current master.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
In case for doesn't get a body, raise the appropriate, descriptive error
instead of an IndexOutOfBounds one. Also updated the failing test case.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Closes#880. The changes compared to the pull request are:
- defn-alias and defmacro-alias are moved to contrib instead of being
fully removed.
- Minor documentation fixes, that were left in after the redundant
symbol removals.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Fixed up the documentation language here and there, related to the alias
removals in previous commits.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Since slice was renamed to cut, update some newly introduced functions
and macros that were using slice, to use cut instead.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>