{"action":"created","issue":{"url":"https://api.github.com/repos/hylang/hy/issues/1016","repository_url":"https://api.github.com/repos/hylang/hy","labels_url":"https://api.github.com/repos/hylang/hy/issues/1016/labels{/name}","comments_url":"https://api.github.com/repos/hylang/hy/issues/1016/comments","events_url":"https://api.github.com/repos/hylang/hy/issues/1016/events","html_url":"https://github.com/hylang/hy/issues/1016","id":128018550,"number":1016,"title":"Exception when importing hy.core.macros from Python","user":{"login":"timmartin","id":56920,"avatar_url":"https://avatars.githubusercontent.com/u/56920?v=3","gravatar_id":"","url":"https://api.github.com/users/timmartin","html_url":"https://github.com/timmartin","followers_url":"https://api.github.com/users/timmartin/followers","following_url":"https://api.github.com/users/timmartin/following{/other_user}","gists_url":"https://api.github.com/users/timmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/timmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timmartin/subscriptions","organizations_url":"https://api.github.com/users/timmartin/orgs","repos_url":"https://api.github.com/users/timmartin/repos","events_url":"https://api.github.com/users/timmartin/events{/privacy}","received_events_url":"https://api.github.com/users/timmartin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-01-21T21:00:59Z","updated_at":"2016-10-10T23:13:22Z","closed_at":null,"body":"If I open a Python 3.4 REPL and type `import hy.core.macros`, it throws an exception:\r\n\r\n    >>> import hy.core.macros\r\n    Traceback (most recent call last):\r\n      File \"/home/timm/dev/hy/hy/macros.py\", line 184, in macroexpand_1\r\n        obj = wrap_value(m(*ntree[1:], **opts))\r\n      File \"<eval_body>\", line 1, in _hy_anon_fn_2\r\n    NameError: name 'is_empty' is not defined\r\n    \r\n    During handling of the above exception, another exception occurred:\r\n    \r\n    Traceback (most recent call last):\r\n      File \"<stdin>\", line 1, in <module>\r\n      File \"<frozen importlib._bootstrap>\", line 2237, in _find_and_load\r\n      File \"<frozen importlib._bootstrap>\", line 2226, in _find_and_load_unlocked\r\n      File \"<frozen importlib._bootstrap>\", line 1191, in _load_unlocked\r\n      File \"<frozen importlib._bootstrap>\", line 1161, in _load_backward_compatible\r\n      File \"/home/timm/dev/hy/hy/importer.py\", line 188, in load_module\r\n        self.path)\r\n      File \"/home/timm/dev/hy/hy/importer.py\", line 76, in import_file_to_module\r\n        _ast = import_file_to_ast(fpath, module_name)\r\n      File \"/home/timm/dev/hy/hy/importer.py\", line 68, in import_file_to_ast\r\n        return hy_compile(import_file_to_hst(fpath), module_name)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 2596, in hy_compile\r\n        result = compiler.compile(tree)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 433, in compile\r\n        ret = self.compile_atom(_type, tree)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 425, in compile_atom\r\n        ret = _compile_table[atom_type](self, atom)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 627, in compile_raw_list\r\n        ret = self._compile_branch(entries)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 489, in _compile_branch\r\n        return _branch(self.compile(expr) for expr in exprs)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 316, in _branch\r\n        results = list(results)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 489, in <genexpr>\r\n        return _branch(self.compile(expr) for expr in exprs)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 433, in compile\r\n        ret = self.compile_atom(_type, tree)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 425, in compile_atom\r\n        ret = _compile_table[atom_type](self, atom)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 2006, in compile_expression\r\n        ret = self.compile_atom(fn, expression)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 425, in compile_atom\r\n        ret = _compile_table[atom_type](self, atom)\r\n        \r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 366, in checker\r\n        return fn(self, expression)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 2450, in compile_macro\r\n        ret = self._compile_time_hack(new_expression)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 2428, in _compile_time_hack\r\n        self.module_name)\r\n      File \"/home/timm/dev/hy/hy/importer.py\", line 116, in hy_eval\r\n        _ast, expr = hy_compile(hytree, module_name, get_expr=True)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 2596, in hy_compile\r\n        result = compiler.compile(tree)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 433, in compile\r\n        ret = self.compile_atom(_type, tree)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 425, in compile_atom\r\n        ret = _compile_table[atom_type](self, atom)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 2006, in compile_expression\r\n        ret = self.compile_atom(fn, expression)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 425, in compile_atom\r\n        ret = _compile_table[atom_type](self, atom)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 366, in checker\r\n        return fn(self, expression)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 1418, in compile_decorate_expression\r\n        fn = self.compile(expr.pop(-1))\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 433, in compile\r\n        ret = self.compile_atom(_type, tree)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 425, in compile_atom\r\n        ret = _compile_table[atom_type](self, atom)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 2006, in compile_expression\r\n        ret = self.compile_atom(fn, expression)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 425, in compile_atom\r\n        ret = _compile_table[atom_type](self, atom)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 366, in checker\r\n        return fn(self, expression)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 2301, in compile_function_def\r\n        body = self._compile_branch(expression)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 489, in _compile_branch\r\n        return _branch(self.compile(expr) for expr in exprs)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 316, in _branch\r\n        results = list(results)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 489, in <genexpr>\r\n        return _branch(self.compile(expr) for expr in exprs)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 433, in compile\r\n        ret = self.compile_atom(_type, tree)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 425, in compile_atom\r\n        ret = _compile_table[atom_type](self, atom)\r\n      File \"/home/timm/dev/hy/hy/compiler.py\", line 1992, in compile_expression\r\n        expression = macroexpand(expression, self)\r\n      File \"/home/timm/dev/hy/hy/macros.py\", line 149, in macroexpand\r\n        tree = macroexpand_1(tree, compiler)\r\n      File \"/home/timm/dev/hy/hy/macros.py\", line 191, in macroexpand_1\r\n        raise HyMacroExpansionError(tree, msg)\r\n    hy.errors.HyMacroExpansionError:   File \"/home/timm/dev/hy/hy/core/macros.hy\", line 110, column 3\r\n    \r\n        (cond\r\n        ^----\r\n         [(odd? (len args))\r\n      ---------------------\r\n          (macro-error args \"`for' requires an even number of args.\")]\r\n      ----------------------------------------------------------------\r\n         [(empty? body)\r\n      -----------------\r\n          (macro-error None \"`for' requires a body to evaluate\")]\r\n      -----------------------------------------------------------\r\n         [(empty? args) `(do ~@body ~@belse)]\r\n      ---------------------------------------\r\n         [(= (len args) 2) `(for* [~@args] (do ~@body) ~@belse)]\r\n      ----------------------------------------------------------\r\n         [true\r\n      --------\r\n           (let [alist (cut args 0 nil 2)]\r\n      -----------------------------------\r\n            `(for* [(, ~@alist) (genexpr (, ~@alist) [~@args])] (do ~@body) ~@belse))]))\r\n      --------------------------------------------------------------------------------^\r\n    HyMacroExpansionError: b'expanding `cond\\': NameError(\"name \\'is_empty\\' is not defined\",)'\r\n\r\nThis is with the current development branch (f9cf39ee738c). I don't see this with the current stable release (0.11.1)."},"comment":{"url":"https://api.github.com/repos/hylang/hy/issues/comments/252770568","html_url":"https://github.com/hylang/hy/issues/1016#issuecomment-252770568","issue_url":"https://api.github.com/repos/hylang/hy/issues/1016","id":252770568,"user":{"login":"kirbyfan64","id":1690697,"avatar_url":"https://avatars.githubusercontent.com/u/1690697?v=3","gravatar_id":"","url":"https://api.github.com/users/kirbyfan64","html_url":"https://github.com/kirbyfan64","followers_url":"https://api.github.com/users/kirbyfan64/followers","following_url":"https://api.github.com/users/kirbyfan64/following{/other_user}","gists_url":"https://api.github.com/users/kirbyfan64/gists{/gist_id}","starred_url":"https://api.github.com/users/kirbyfan64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirbyfan64/subscriptions","organizations_url":"https://api.github.com/users/kirbyfan64/orgs","repos_url":"https://api.github.com/users/kirbyfan64/repos","events_url":"https://api.github.com/users/kirbyfan64/events{/privacy}","received_events_url":"https://api.github.com/users/kirbyfan64/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T23:13:22Z","updated_at":"2016-10-10T23:13:22Z","body":"Not exactly sure how to solve this cleanly..."}}
{"actor":{"display_login":"kirbyfan64"}}