We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Make `help()` recogonize macros as well
It would be nice to have `help` recogonize macros as well. Ideas welcome...


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `hy/macros.py`
Content:
```
1 # Copyright 2017 the authors.
2 # This file is part of Hy, which is free software licensed under the Expat
3 # license. See the LICENSE.
4 
5 from inspect import getargspec, formatargspec
6 from hy.models import replace_hy_obj, HyExpression, HySymbol
7 
8 from hy.errors import HyTypeError, HyMacroExpansionError
9 
10 from collections import defaultdict
11 
12 CORE_MACROS = [
13     "hy.core.bootstrap",
14 ]
15 
16 EXTRA_MACROS = [
17     "hy.core.macros",
18 ]
19 
20 _hy_macros = defaultdict(dict)
21 _hy_tag = defaultdict(dict)
22 
23 
24 def macro(name):
25     """Decorator to define a macro called `name`.
26 
27     This stores the macro `name` in the namespace for the module where it is
28     defined.
29 
30     If the module where it is defined is in `hy.core`, then the macro is stored
31     in the default `None` namespace.
32 
33     This function is called from the `defmacro` special form in the compiler.
34 
35     """
36     def _(fn):
37         try:
38             argspec = getargspec(fn)
39             fn._hy_macro_pass_compiler = argspec.keywords is not None
40         except Exception:
41             # An exception might be raised if fn has arguments with
42             # names that are invalid in Python.
43             fn._hy_macro_pass_compiler = False
44 
45         module_name = fn.__module__
46         if module_name.startswith("hy.core"):
47             module_name = None
48         _hy_macros[module_name][name] = fn
49         return fn
50     return _
51 
52 
53 def tag(name):
54     """Decorator to define a tag macro called `name`.
55 
56     This stores the macro `name` in the namespace for the module where it is
57     defined.
58 
59     If the module where it is defined is in `hy.core`, then the macro is stored
60     in the default `None` namespace.
61 
62     This function is called from the `deftag` special form in the compiler.
63 
64     """
65     def _(fn):
66         module_name = fn.__module__
67         if module_name.startswith("hy.core"):
68             module_name = None
69         _hy_tag[module_name][name] = fn
70 
71         return fn
72     return _
73 
74 
75 def require(source_module, target_module,
76             all_macros=False, assignments={}, prefix=""):
77     """Load macros from `source_module` in the namespace of
78     `target_module`. `assignments` maps old names to new names, but is
79     ignored if `all_macros` is true. If `prefix` is nonempty, it is
80     prepended to the name of each imported macro. (This means you get
81     macros named things like "mymacromodule.mymacro", which looks like
82     an attribute of a module, although it's actually just a symbol
83     with a period in its name.)
84 
85     This function is called from the `require` special form in the compiler.
86 
87     """
88 
89     seen_names = set()
90     if prefix:
91         prefix += "."
92 
93     for d in _hy_macros, _hy_tag:
94         for name, macro in d[source_module].items():
95             seen_names.add(name)
96             if all_macros:
97                 d[target_module][prefix + name] = macro
98             elif name in assignments:
99                 d[target_module][prefix + assignments[name]] = macro
100 
101     if not all_macros:
102         unseen = frozenset(assignments.keys()).difference(seen_names)
103         if unseen:
104             raise ImportError("cannot require names: " + repr(list(unseen)))
105 
106 
107 def load_macros(module_name):
108     """Load the hy builtin macros for module `module_name`.
109 
110     Modules from `hy.core` can only use the macros from CORE_MACROS.
111     Other modules get the macros from CORE_MACROS and EXTRA_MACROS.
112 
113     """
114 
115     def _import(module, module_name=module_name):
116         "__import__ a module, avoiding recursions"
117         if module != module_name:
118             __import__(module)
119 
120     for module in CORE_MACROS:
121         _import(module)
122 
123     if module_name.startswith("hy.core"):
124         return
125 
126     for module in EXTRA_MACROS:
127         _import(module)
128 
129 
130 def make_empty_fn_copy(fn):
131     try:
132         # This might fail if fn has parameters with funny names, like o!n. In
133         # such a case, we return a generic function that ensures the program
134         # can continue running. Unfortunately, the error message that might get
135         # raised later on while expanding a macro might not make sense at all.
136 
137         argspec = getargspec(fn)
138         formatted_args = formatargspec(*argspec)
139 
140         fn_str = 'lambda {}: None'.format(
141             formatted_args.lstrip('(').rstrip(')'))
142         empty_fn = eval(fn_str)
143 
144     except Exception:
145 
146         def empty_fn(*args, **kwargs):
147             None
148 
149     return empty_fn
150 
151 
152 def macroexpand(tree, compiler):
153     """Expand the toplevel macros for the `tree`.
154 
155     Load the macros from the given `module_name`, then expand the (top-level)
156     macros in `tree` until it stops changing.
157 
158     """
159     load_macros(compiler.module_name)
160     old = None
161     while old != tree:
162         old = tree
163         tree = macroexpand_1(tree, compiler)
164     return tree
165 
166 
167 def macroexpand_1(tree, compiler):
168     """Expand the toplevel macro from `tree` once, in the context of
169     `module_name`."""
170     if isinstance(tree, HyExpression):
171         if tree == []:
172             return tree
173 
174         fn = tree[0]
175         if fn in ("quote", "quasiquote"):
176             return tree
177         ntree = HyExpression(tree[:])
178         ntree.replace(tree)
179 
180         opts = {}
181 
182         if isinstance(fn, HySymbol):
183             m = _hy_macros[compiler.module_name].get(fn)
184             if m is None:
185                 m = _hy_macros[None].get(fn)
186             if m is not None:
187                 if m._hy_macro_pass_compiler:
188                     opts['compiler'] = compiler
189 
190                 try:
191                     m_copy = make_empty_fn_copy(m)
192                     m_copy(*ntree[1:], **opts)
193                 except TypeError as e:
194                     msg = "expanding `" + str(tree[0]) + "': "
195                     msg += str(e).replace("<lambda>()", "", 1).strip()
196                     raise HyMacroExpansionError(tree, msg)
197 
198                 try:
199                     obj = m(*ntree[1:], **opts)
200                 except HyTypeError as e:
201                     if e.expression is None:
202                         e.expression = tree
203                     raise
204                 except Exception as e:
205                     msg = "expanding `" + str(tree[0]) + "': " + repr(e)
206                     raise HyMacroExpansionError(tree, msg)
207                 replace_hy_obj(obj, tree)
208                 return obj
209         return ntree
210     return tree
211 
212 
213 def tag_macroexpand(tag, tree, compiler):
214     """Expand the tag macro "tag" with argument `tree`."""
215     load_macros(compiler.module_name)
216 
217     tag_macro = _hy_tag[compiler.module_name].get(tag)
218     if tag_macro is None:
219         try:
220             tag_macro = _hy_tag[None][tag]
221         except KeyError:
222             raise HyTypeError(
223                 tag,
224                 "`{0}' is not a defined tag macro.".format(tag)
225             )
226 
227     expr = tag_macro(tree)
228     return replace_hy_obj(expr, tree)
229
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/hy/macros.py b/hy/macros.py
--- a/hy/macros.py
+++ b/hy/macros.py
@@ -34,6 +34,7 @@
 
     """
     def _(fn):
+        fn.__name__ = "({})".format(name)
         try:
             argspec = getargspec(fn)
             fn._hy_macro_pass_compiler = argspec.keywords is not None
@@ -63,6 +64,7 @@
 
     """
     def _(fn):
+        fn.__name__ = '#{}'.format(name)
         module_name = fn.__module__
         if module_name.startswith("hy.core"):
             module_name = None

{"golden_diff": "diff --git a/hy/macros.py b/hy/macros.py\n--- a/hy/macros.py\n+++ b/hy/macros.py\n@@ -34,6 +34,7 @@\n \n     \"\"\"\n     def _(fn):\n+        fn.__name__ = \"({})\".format(name)\n         try:\n             argspec = getargspec(fn)\n             fn._hy_macro_pass_compiler = argspec.keywords is not None\n@@ -63,6 +64,7 @@\n \n     \"\"\"\n     def _(fn):\n+        fn.__name__ = '#{}'.format(name)\n         module_name = fn.__module__\n         if module_name.startswith(\"hy.core\"):\n             module_name = None\n", "issue": "Make `help()` recogonize macros as well\nIt would be nice to have `help` recogonize macros as well. Ideas welcome...\n\n", "before_files": [{"content": "# Copyright 2017 the authors.\n# This file is part of Hy, which is free software licensed under the Expat\n# license. See the LICENSE.\n\nfrom inspect import getargspec, formatargspec\nfrom hy.models import replace_hy_obj, HyExpression, HySymbol\n\nfrom hy.errors import HyTypeError, HyMacroExpansionError\n\nfrom collections import defaultdict\n\nCORE_MACROS = [\n    \"hy.core.bootstrap\",\n]\n\nEXTRA_MACROS = [\n    \"hy.core.macros\",\n]\n\n_hy_macros = defaultdict(dict)\n_hy_tag = defaultdict(dict)\n\n\ndef macro(name):\n    \"\"\"Decorator to define a macro called `name`.\n\n    This stores the macro `name` in the namespace for the module where it is\n    defined.\n\n    If the module where it is defined is in `hy.core`, then the macro is stored\n    in the default `None` namespace.\n\n    This function is called from the `defmacro` special form in the compiler.\n\n    \"\"\"\n    def _(fn):\n        try:\n            argspec = getargspec(fn)\n            fn._hy_macro_pass_compiler = argspec.keywords is not None\n        except Exception:\n            # An exception might be raised if fn has arguments with\n            # names that are invalid in Python.\n            fn._hy_macro_pass_compiler = False\n\n        module_name = fn.__module__\n        if module_name.startswith(\"hy.core\"):\n            module_name = None\n        _hy_macros[module_name][name] = fn\n        return fn\n    return _\n\n\ndef tag(name):\n    \"\"\"Decorator to define a tag macro called `name`.\n\n    This stores the macro `name` in the namespace for the module where it is\n    defined.\n\n    If the module where it is defined is in `hy.core`, then the macro is stored\n    in the default `None` namespace.\n\n    This function is called from the `deftag` special form in the compiler.\n\n    \"\"\"\n    def _(fn):\n        module_name = fn.__module__\n        if module_name.startswith(\"hy.core\"):\n            module_name = None\n        _hy_tag[module_name][name] = fn\n\n        return fn\n    return _\n\n\ndef require(source_module, target_module,\n            all_macros=False, assignments={}, prefix=\"\"):\n    \"\"\"Load macros from `source_module` in the namespace of\n    `target_module`. `assignments` maps old names to new names, but is\n    ignored if `all_macros` is true. If `prefix` is nonempty, it is\n    prepended to the name of each imported macro. (This means you get\n    macros named things like \"mymacromodule.mymacro\", which looks like\n    an attribute of a module, although it's actually just a symbol\n    with a period in its name.)\n\n    This function is called from the `require` special form in the compiler.\n\n    \"\"\"\n\n    seen_names = set()\n    if prefix:\n        prefix += \".\"\n\n    for d in _hy_macros, _hy_tag:\n        for name, macro in d[source_module].items():\n            seen_names.add(name)\n            if all_macros:\n                d[target_module][prefix + name] = macro\n            elif name in assignments:\n                d[target_module][prefix + assignments[name]] = macro\n\n    if not all_macros:\n        unseen = frozenset(assignments.keys()).difference(seen_names)\n        if unseen:\n            raise ImportError(\"cannot require names: \" + repr(list(unseen)))\n\n\ndef load_macros(module_name):\n    \"\"\"Load the hy builtin macros for module `module_name`.\n\n    Modules from `hy.core` can only use the macros from CORE_MACROS.\n    Other modules get the macros from CORE_MACROS and EXTRA_MACROS.\n\n    \"\"\"\n\n    def _import(module, module_name=module_name):\n        \"__import__ a module, avoiding recursions\"\n        if module != module_name:\n            __import__(module)\n\n    for module in CORE_MACROS:\n        _import(module)\n\n    if module_name.startswith(\"hy.core\"):\n        return\n\n    for module in EXTRA_MACROS:\n        _import(module)\n\n\ndef make_empty_fn_copy(fn):\n    try:\n        # This might fail if fn has parameters with funny names, like o!n. In\n        # such a case, we return a generic function that ensures the program\n        # can continue running. Unfortunately, the error message that might get\n        # raised later on while expanding a macro might not make sense at all.\n\n        argspec = getargspec(fn)\n        formatted_args = formatargspec(*argspec)\n\n        fn_str = 'lambda {}: None'.format(\n            formatted_args.lstrip('(').rstrip(')'))\n        empty_fn = eval(fn_str)\n\n    except Exception:\n\n        def empty_fn(*args, **kwargs):\n            None\n\n    return empty_fn\n\n\ndef macroexpand(tree, compiler):\n    \"\"\"Expand the toplevel macros for the `tree`.\n\n    Load the macros from the given `module_name`, then expand the (top-level)\n    macros in `tree` until it stops changing.\n\n    \"\"\"\n    load_macros(compiler.module_name)\n    old = None\n    while old != tree:\n        old = tree\n        tree = macroexpand_1(tree, compiler)\n    return tree\n\n\ndef macroexpand_1(tree, compiler):\n    \"\"\"Expand the toplevel macro from `tree` once, in the context of\n    `module_name`.\"\"\"\n    if isinstance(tree, HyExpression):\n        if tree == []:\n            return tree\n\n        fn = tree[0]\n        if fn in (\"quote\", \"quasiquote\"):\n            return tree\n        ntree = HyExpression(tree[:])\n        ntree.replace(tree)\n\n        opts = {}\n\n        if isinstance(fn, HySymbol):\n            m = _hy_macros[compiler.module_name].get(fn)\n            if m is None:\n                m = _hy_macros[None].get(fn)\n            if m is not None:\n                if m._hy_macro_pass_compiler:\n                    opts['compiler'] = compiler\n\n                try:\n                    m_copy = make_empty_fn_copy(m)\n                    m_copy(*ntree[1:], **opts)\n                except TypeError as e:\n                    msg = \"expanding `\" + str(tree[0]) + \"': \"\n                    msg += str(e).replace(\"<lambda>()\", \"\", 1).strip()\n                    raise HyMacroExpansionError(tree, msg)\n\n                try:\n                    obj = m(*ntree[1:], **opts)\n                except HyTypeError as e:\n                    if e.expression is None:\n                        e.expression = tree\n                    raise\n                except Exception as e:\n                    msg = \"expanding `\" + str(tree[0]) + \"': \" + repr(e)\n                    raise HyMacroExpansionError(tree, msg)\n                replace_hy_obj(obj, tree)\n                return obj\n        return ntree\n    return tree\n\n\ndef tag_macroexpand(tag, tree, compiler):\n    \"\"\"Expand the tag macro \"tag\" with argument `tree`.\"\"\"\n    load_macros(compiler.module_name)\n\n    tag_macro = _hy_tag[compiler.module_name].get(tag)\n    if tag_macro is None:\n        try:\n            tag_macro = _hy_tag[None][tag]\n        except KeyError:\n            raise HyTypeError(\n                tag,\n                \"`{0}' is not a defined tag macro.\".format(tag)\n            )\n\n    expr = tag_macro(tree)\n    return replace_hy_obj(expr, tree)\n", "path": "hy/macros.py"}], "after_files": [{"content": "# Copyright 2017 the authors.\n# This file is part of Hy, which is free software licensed under the Expat\n# license. See the LICENSE.\n\nfrom inspect import getargspec, formatargspec\nfrom hy.models import replace_hy_obj, HyExpression, HySymbol\n\nfrom hy.errors import HyTypeError, HyMacroExpansionError\n\nfrom collections import defaultdict\n\nCORE_MACROS = [\n    \"hy.core.bootstrap\",\n]\n\nEXTRA_MACROS = [\n    \"hy.core.macros\",\n]\n\n_hy_macros = defaultdict(dict)\n_hy_tag = defaultdict(dict)\n\n\ndef macro(name):\n    \"\"\"Decorator to define a macro called `name`.\n\n    This stores the macro `name` in the namespace for the module where it is\n    defined.\n\n    If the module where it is defined is in `hy.core`, then the macro is stored\n    in the default `None` namespace.\n\n    This function is called from the `defmacro` special form in the compiler.\n\n    \"\"\"\n    def _(fn):\n        fn.__name__ = \"({})\".format(name)\n        try:\n            argspec = getargspec(fn)\n            fn._hy_macro_pass_compiler = argspec.keywords is not None\n        except Exception:\n            # An exception might be raised if fn has arguments with\n            # names that are invalid in Python.\n            fn._hy_macro_pass_compiler = False\n\n        module_name = fn.__module__\n        if module_name.startswith(\"hy.core\"):\n            module_name = None\n        _hy_macros[module_name][name] = fn\n        return fn\n    return _\n\n\ndef tag(name):\n    \"\"\"Decorator to define a tag macro called `name`.\n\n    This stores the macro `name` in the namespace for the module where it is\n    defined.\n\n    If the module where it is defined is in `hy.core`, then the macro is stored\n    in the default `None` namespace.\n\n    This function is called from the `deftag` special form in the compiler.\n\n    \"\"\"\n    def _(fn):\n        fn.__name__ = '#{}'.format(name)\n        module_name = fn.__module__\n        if module_name.startswith(\"hy.core\"):\n            module_name = None\n        _hy_tag[module_name][name] = fn\n\n        return fn\n    return _\n\n\ndef require(source_module, target_module,\n            all_macros=False, assignments={}, prefix=\"\"):\n    \"\"\"Load macros from `source_module` in the namespace of\n    `target_module`. `assignments` maps old names to new names, but is\n    ignored if `all_macros` is true. If `prefix` is nonempty, it is\n    prepended to the name of each imported macro. (This means you get\n    macros named things like \"mymacromodule.mymacro\", which looks like\n    an attribute of a module, although it's actually just a symbol\n    with a period in its name.)\n\n    This function is called from the `require` special form in the compiler.\n\n    \"\"\"\n\n    seen_names = set()\n    if prefix:\n        prefix += \".\"\n\n    for d in _hy_macros, _hy_tag:\n        for name, macro in d[source_module].items():\n            seen_names.add(name)\n            if all_macros:\n                d[target_module][prefix + name] = macro\n            elif name in assignments:\n                d[target_module][prefix + assignments[name]] = macro\n\n    if not all_macros:\n        unseen = frozenset(assignments.keys()).difference(seen_names)\n        if unseen:\n            raise ImportError(\"cannot require names: \" + repr(list(unseen)))\n\n\ndef load_macros(module_name):\n    \"\"\"Load the hy builtin macros for module `module_name`.\n\n    Modules from `hy.core` can only use the macros from CORE_MACROS.\n    Other modules get the macros from CORE_MACROS and EXTRA_MACROS.\n\n    \"\"\"\n\n    def _import(module, module_name=module_name):\n        \"__import__ a module, avoiding recursions\"\n        if module != module_name:\n            __import__(module)\n\n    for module in CORE_MACROS:\n        _import(module)\n\n    if module_name.startswith(\"hy.core\"):\n        return\n\n    for module in EXTRA_MACROS:\n        _import(module)\n\n\ndef make_empty_fn_copy(fn):\n    try:\n        # This might fail if fn has parameters with funny names, like o!n. In\n        # such a case, we return a generic function that ensures the program\n        # can continue running. Unfortunately, the error message that might get\n        # raised later on while expanding a macro might not make sense at all.\n\n        argspec = getargspec(fn)\n        formatted_args = formatargspec(*argspec)\n\n        fn_str = 'lambda {}: None'.format(\n            formatted_args.lstrip('(').rstrip(')'))\n        empty_fn = eval(fn_str)\n\n    except Exception:\n\n        def empty_fn(*args, **kwargs):\n            None\n\n    return empty_fn\n\n\ndef macroexpand(tree, compiler):\n    \"\"\"Expand the toplevel macros for the `tree`.\n\n    Load the macros from the given `module_name`, then expand the (top-level)\n    macros in `tree` until it stops changing.\n\n    \"\"\"\n    load_macros(compiler.module_name)\n    old = None\n    while old != tree:\n        old = tree\n        tree = macroexpand_1(tree, compiler)\n    return tree\n\n\ndef macroexpand_1(tree, compiler):\n    \"\"\"Expand the toplevel macro from `tree` once, in the context of\n    `module_name`.\"\"\"\n    if isinstance(tree, HyExpression):\n        if tree == []:\n            return tree\n\n        fn = tree[0]\n        if fn in (\"quote\", \"quasiquote\"):\n            return tree\n        ntree = HyExpression(tree[:])\n        ntree.replace(tree)\n\n        opts = {}\n\n        if isinstance(fn, HySymbol):\n            m = _hy_macros[compiler.module_name].get(fn)\n            if m is None:\n                m = _hy_macros[None].get(fn)\n            if m is not None:\n                if m._hy_macro_pass_compiler:\n                    opts['compiler'] = compiler\n\n                try:\n                    m_copy = make_empty_fn_copy(m)\n                    m_copy(*ntree[1:], **opts)\n                except TypeError as e:\n                    msg = \"expanding `\" + str(tree[0]) + \"': \"\n                    msg += str(e).replace(\"<lambda>()\", \"\", 1).strip()\n                    raise HyMacroExpansionError(tree, msg)\n\n                try:\n                    obj = m(*ntree[1:], **opts)\n                except HyTypeError as e:\n                    if e.expression is None:\n                        e.expression = tree\n                    raise\n                except Exception as e:\n                    msg = \"expanding `\" + str(tree[0]) + \"': \" + repr(e)\n                    raise HyMacroExpansionError(tree, msg)\n                replace_hy_obj(obj, tree)\n                return obj\n        return ntree\n    return tree\n\n\ndef tag_macroexpand(tag, tree, compiler):\n    \"\"\"Expand the tag macro \"tag\" with argument `tree`.\"\"\"\n    load_macros(compiler.module_name)\n\n    tag_macro = _hy_tag[compiler.module_name].get(tag)\n    if tag_macro is None:\n        try:\n            tag_macro = _hy_tag[None][tag]\n        except KeyError:\n            raise HyTypeError(\n                tag,\n                \"`{0}' is not a defined tag macro.\".format(tag)\n            )\n\n    expr = tag_macro(tree)\n    return replace_hy_obj(expr, tree)\n", "path": "hy/macros.py"}]}