prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Allow macros to return None
  ```
   (defmacro foo [])
   (foo) 
  ```
  
  Will break as macros are not handling the NoneType yet
  
  
  --- 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 (c) 2013 Paul Tagliamonte <paultag@debian.org>
  2 #
  3 # Permission is hereby granted, free of charge, to any person obtaining a
  4 # copy of this software and associated documentation files (the "Software"),
  5 # to deal in the Software without restriction, including without limitation
  6 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  7 # and/or sell copies of the Software, and to permit persons to whom the
  8 # Software is furnished to do so, subject to the following conditions:
  9 #
  10 # The above copyright notice and this permission notice shall be included in
  11 # all copies or substantial portions of the Software.
  12 #
  13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  16 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  19 # DEALINGS IN THE SOFTWARE.
  20 
  21 from hy.models.expression import HyExpression
  22 from hy.models.string import HyString
  23 from hy.models.symbol import HySymbol
  24 from hy.models.list import HyList
  25 from hy.models.integer import HyInteger
  26 from hy.models.float import HyFloat
  27 from hy.models.complex import HyComplex
  28 from hy.models.dict import HyDict
  29 from hy._compat import str_type
  30 
  31 from collections import defaultdict
  32 
  33 
  34 CORE_MACROS = [
  35     "hy.core.bootstrap",
  36 ]
  37 
  38 EXTRA_MACROS = [
  39     "hy.core.macros",
  40 ]
  41 
  42 _hy_macros = defaultdict(dict)
  43 
  44 
  45 def macro(name):
  46     """Decorator to define a macro called `name`.
  47 
  48     This stores the macro `name` in the namespace for the module where it is
  49     defined.
  50 
  51     If the module where it is defined is in `hy.core`, then the macro is stored
  52     in the default `None` namespace.
  53 
  54     This function is called from the `defmacro` special form in the compiler.
  55 
  56     """
  57     def _(fn):
  58         module_name = fn.__module__
  59         if module_name.startswith("hy.core"):
  60             module_name = None
  61         _hy_macros[module_name][name] = fn
  62         return fn
  63     return _
  64 
  65 
  66 def require(source_module, target_module):
  67     """Load the macros from `source_module` in the namespace of
  68     `target_module`.
  69 
  70     This function is called from the `require` special form in the compiler.
  71 
  72     """
  73     macros = _hy_macros[source_module]
  74     refs = _hy_macros[target_module]
  75     for name, macro in macros.items():
  76         refs[name] = macro
  77 
  78 
  79 # type -> wrapping function mapping for _wrap_value
  80 _wrappers = {
  81     int: HyInteger,
  82     bool: lambda x: HySymbol("True") if x else HySymbol("False"),
  83     float: HyFloat,
  84     complex: HyComplex,
  85     str_type: HyString,
  86     dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())),
  87     list: lambda l: HyList(_wrap_value(x) for x in l)
  88 }
  89 
  90 
  91 def _wrap_value(x):
  92     """Wrap `x` into the corresponding Hy type.
  93 
  94     This allows a macro to return an unquoted expression transparently.
  95 
  96     """
  97     wrapper = _wrappers.get(type(x))
  98     if wrapper is None:
  99         return x
  100     else:
  101         return wrapper(x)
  102 
  103 
  104 def load_macros(module_name):
  105     """Load the hy builtin macros for module `module_name`.
  106 
  107     Modules from `hy.core` can only use the macros from CORE_MACROS.
  108     Other modules get the macros from CORE_MACROS and EXTRA_MACROS.
  109 
  110     """
  111 
  112     def _import(module, module_name=module_name):
  113         "__import__ a module, avoiding recursions"
  114         if module != module_name:
  115             __import__(module)
  116 
  117     for module in CORE_MACROS:
  118         _import(module)
  119 
  120     if module_name.startswith("hy.core"):
  121         return
  122 
  123     for module in EXTRA_MACROS:
  124         _import(module)
  125 
  126 
  127 def macroexpand(tree, module_name):
  128     """Expand the toplevel macros for the `tree`.
  129 
  130     Load the macros from the given `module_name`, then expand the (top-level)
  131     macros in `tree` until it stops changing.
  132 
  133     """
  134     load_macros(module_name)
  135     old = None
  136     while old != tree:
  137         old = tree
  138         tree = macroexpand_1(tree, module_name)
  139     return tree
  140 
  141 
  142 def macroexpand_1(tree, module_name):
  143     """Expand the toplevel macro from `tree` once, in the context of
  144     `module_name`."""
  145     if isinstance(tree, HyExpression):
  146         if tree == []:
  147             return tree
  148 
  149         fn = tree[0]
  150         if fn in ("quote", "quasiquote"):
  151             return tree
  152         ntree = HyExpression(tree[:])
  153         ntree.replace(tree)
  154 
  155         if isinstance(fn, HyString):
  156             m = _hy_macros[module_name].get(fn)
  157             if m is None:
  158                 m = _hy_macros[None].get(fn)
  159             if m is not None:
  160                 obj = _wrap_value(m(*ntree[1:]))
  161                 obj.replace(tree)
  162                 return obj
  163 
  164         return ntree
  165     return tree
  166
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/hy/macros.py b/hy/macros.py
  --- a/hy/macros.py
  +++ b/hy/macros.py
  @@ -84,7 +84,8 @@
       complex: HyComplex,
       str_type: HyString,
       dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())),
  -    list: lambda l: HyList(_wrap_value(x) for x in l)
  +    list: lambda l: HyList(_wrap_value(x) for x in l),
  +    type(None): lambda foo: HySymbol("None"),
   }
  
verification_info: {"golden_diff": "diff --git a/hy/macros.py b/hy/macros.py\n--- a/hy/macros.py\n+++ b/hy/macros.py\n@@ -84,7 +84,8 @@\n     complex: HyComplex,\n     str_type: HyString,\n     dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())),\n-    list: lambda l: HyList(_wrap_value(x) for x in l)\n+    list: lambda l: HyList(_wrap_value(x) for x in l),\n+    type(None): lambda foo: HySymbol(\"None\"),\n }\n", "issue": "Allow macros to return None\n```\n (defmacro foo [])\n (foo) \n```\n\nWill break as macros are not handling the NoneType yet\n\n", "before_files": [{"content": "# Copyright (c) 2013 Paul Tagliamonte <paultag@debian.org>\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software and associated documentation files (the \"Software\"),\n# to deal in the Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish, distribute, sublicense,\n# and/or sell copies of the Software, and to permit persons to whom the\n# Software is furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n# DEALINGS IN THE SOFTWARE.\n\nfrom hy.models.expression import HyExpression\nfrom hy.models.string import HyString\nfrom hy.models.symbol import HySymbol\nfrom hy.models.list import HyList\nfrom hy.models.integer import HyInteger\nfrom hy.models.float import HyFloat\nfrom hy.models.complex import HyComplex\nfrom hy.models.dict import HyDict\nfrom hy._compat import str_type\n\nfrom collections import defaultdict\n\n\nCORE_MACROS = [\n    \"hy.core.bootstrap\",\n]\n\nEXTRA_MACROS = [\n    \"hy.core.macros\",\n]\n\n_hy_macros = 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        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 require(source_module, target_module):\n    \"\"\"Load the macros from `source_module` in the namespace of\n    `target_module`.\n\n    This function is called from the `require` special form in the compiler.\n\n    \"\"\"\n    macros = _hy_macros[source_module]\n    refs = _hy_macros[target_module]\n    for name, macro in macros.items():\n        refs[name] = macro\n\n\n# type -> wrapping function mapping for _wrap_value\n_wrappers = {\n    int: HyInteger,\n    bool: lambda x: HySymbol(\"True\") if x else HySymbol(\"False\"),\n    float: HyFloat,\n    complex: HyComplex,\n    str_type: HyString,\n    dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())),\n    list: lambda l: HyList(_wrap_value(x) for x in l)\n}\n\n\ndef _wrap_value(x):\n    \"\"\"Wrap `x` into the corresponding Hy type.\n\n    This allows a macro to return an unquoted expression transparently.\n\n    \"\"\"\n    wrapper = _wrappers.get(type(x))\n    if wrapper is None:\n        return x\n    else:\n        return wrapper(x)\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 macroexpand(tree, module_name):\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(module_name)\n    old = None\n    while old != tree:\n        old = tree\n        tree = macroexpand_1(tree, module_name)\n    return tree\n\n\ndef macroexpand_1(tree, module_name):\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        if isinstance(fn, HyString):\n            m = _hy_macros[module_name].get(fn)\n            if m is None:\n                m = _hy_macros[None].get(fn)\n            if m is not None:\n                obj = _wrap_value(m(*ntree[1:]))\n                obj.replace(tree)\n                return obj\n\n        return ntree\n    return tree\n", "path": "hy/macros.py"}], "after_files": [{"content": "# Copyright (c) 2013 Paul Tagliamonte <paultag@debian.org>\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software and associated documentation files (the \"Software\"),\n# to deal in the Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish, distribute, sublicense,\n# and/or sell copies of the Software, and to permit persons to whom the\n# Software is furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n# DEALINGS IN THE SOFTWARE.\n\nfrom hy.models.expression import HyExpression\nfrom hy.models.string import HyString\nfrom hy.models.symbol import HySymbol\nfrom hy.models.list import HyList\nfrom hy.models.integer import HyInteger\nfrom hy.models.float import HyFloat\nfrom hy.models.complex import HyComplex\nfrom hy.models.dict import HyDict\nfrom hy._compat import str_type\n\nfrom collections import defaultdict\n\n\nCORE_MACROS = [\n    \"hy.core.bootstrap\",\n]\n\nEXTRA_MACROS = [\n    \"hy.core.macros\",\n]\n\n_hy_macros = 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        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 require(source_module, target_module):\n    \"\"\"Load the macros from `source_module` in the namespace of\n    `target_module`.\n\n    This function is called from the `require` special form in the compiler.\n\n    \"\"\"\n    macros = _hy_macros[source_module]\n    refs = _hy_macros[target_module]\n    for name, macro in macros.items():\n        refs[name] = macro\n\n\n# type -> wrapping function mapping for _wrap_value\n_wrappers = {\n    int: HyInteger,\n    bool: lambda x: HySymbol(\"True\") if x else HySymbol(\"False\"),\n    float: HyFloat,\n    complex: HyComplex,\n    str_type: HyString,\n    dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())),\n    list: lambda l: HyList(_wrap_value(x) for x in l),\n    type(None): lambda foo: HySymbol(\"None\"),\n}\n\n\ndef _wrap_value(x):\n    \"\"\"Wrap `x` into the corresponding Hy type.\n\n    This allows a macro to return an unquoted expression transparently.\n\n    \"\"\"\n    wrapper = _wrappers.get(type(x))\n    if wrapper is None:\n        return x\n    else:\n        return wrapper(x)\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 macroexpand(tree, module_name):\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(module_name)\n    old = None\n    while old != tree:\n        old = tree\n        tree = macroexpand_1(tree, module_name)\n    return tree\n\n\ndef macroexpand_1(tree, module_name):\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        if isinstance(fn, HyString):\n            m = _hy_macros[module_name].get(fn)\n            if m is None:\n                m = _hy_macros[None].get(fn)\n            if m is not None:\n                obj = _wrap_value(m(*ntree[1:]))\n                obj.replace(tree)\n                return obj\n\n        return ntree\n    return tree\n", "path": "hy/macros.py"}]}