prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Single quote crashes hy2py
  ## x.hy
  
  ```
  '
  ```
  
  ## `hy2py x.hy`
  
  ```
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "hy/cmdline.py", line 406, in hy2py_main
      if stdin_text is None
    File "hy/cmdline.py", line 186, in pretty_error
      print(e, file=sys.stderr)
    File "hy/lex/exceptions.py", line 43, in __str__
      source = self.source.split("\n")
  AttributeError: 'NoneType' object has no attribute 'split'
  ```
  
  --- 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/lex/exceptions.py`
  Content:
  ```
  1 # Copyright (c) 2013 Nicolas Dandrimont <nicolas.dandrimont@crans.org>
  2 # Copyright (c) 2013 Bob Tolbert <bob@tolbert.org>
  3 #
  4 # Permission is hereby granted, free of charge, to any person obtaining a
  5 # copy of this software and associated documentation files (the "Software"),
  6 # to deal in the Software without restriction, including without limitation
  7 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8 # and/or sell copies of the Software, and to permit persons to whom the
  9 # Software is furnished to do so, subject to the following conditions:
  10 #
  11 # The above copyright notice and this permission notice shall be included in
  12 # all copies or substantial portions of the Software.
  13 #
  14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  17 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20 # DEALINGS IN THE SOFTWARE.
  21 
  22 from hy.errors import HyError
  23 
  24 
  25 class LexException(HyError):
  26     """Error during the Lexing of a Hython expression."""
  27     def __init__(self, message, lineno, colno):
  28         super(LexException, self).__init__(message)
  29         self.message = message
  30         self.lineno = lineno
  31         self.colno = colno
  32         self.source = None
  33         self.filename = '<stdin>'
  34 
  35     def __str__(self):
  36         from hy.errors import colored
  37 
  38         line = self.lineno
  39         start = self.colno
  40 
  41         result = ""
  42 
  43         source = self.source.split("\n")
  44 
  45         if line > 0 and start > 0:
  46             result += '  File "%s", line %d, column %d\n\n' % (self.filename,
  47                                                                line,
  48                                                                start)
  49 
  50             if len(self.source) > 0:
  51                 source_line = source[line-1]
  52             else:
  53                 source_line = ""
  54 
  55             result += '  %s\n' % colored.red(source_line)
  56             result += '  %s%s\n' % (' '*(start-1), colored.green('^'))
  57 
  58         result += colored.yellow("LexException: %s\n\n" % self.message)
  59 
  60         return result
  61 
  62 
  63 class PrematureEndOfInput(LexException):
  64     """We got a premature end of input"""
  65     def __init__(self, message):
  66         super(PrematureEndOfInput, self).__init__(message, -1, -1)
  67
  ```
  
  Path: `hy/lex/__init__.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 rply.errors import LexingError
  22 
  23 from hy.lex.exceptions import LexException, PrematureEndOfInput  # NOQA
  24 from hy.lex.lexer import lexer
  25 from hy.lex.parser import parser
  26 
  27 
  28 def tokenize(buf):
  29     """
  30     Tokenize a Lisp file or string buffer into internal Hy objects.
  31     """
  32     try:
  33         return parser.parse(lexer.lex(buf))
  34     except LexingError as e:
  35         pos = e.getsourcepos()
  36         raise LexException("Could not identify the next token.",
  37                            pos.lineno, pos.colno)
  38     except LexException as e:
  39         if e.source is None:
  40             e.source = buf
  41         raise
  42
  ```
  --- 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/lex/__init__.py b/hy/lex/__init__.py
  --- a/hy/lex/__init__.py
  +++ b/hy/lex/__init__.py
  @@ -34,7 +34,7 @@
       except LexingError as e:
           pos = e.getsourcepos()
           raise LexException("Could not identify the next token.",
  -                           pos.lineno, pos.colno)
  +                           pos.lineno, pos.colno, buf)
       except LexException as e:
           if e.source is None:
               e.source = buf
  diff --git a/hy/lex/exceptions.py b/hy/lex/exceptions.py
  --- a/hy/lex/exceptions.py
  +++ b/hy/lex/exceptions.py
  @@ -24,12 +24,12 @@
   
   class LexException(HyError):
       """Error during the Lexing of a Hython expression."""
  -    def __init__(self, message, lineno, colno):
  +    def __init__(self, message, lineno, colno, source=None):
           super(LexException, self).__init__(message)
           self.message = message
           self.lineno = lineno
           self.colno = colno
  -        self.source = None
  +        self.source = source
           self.filename = '<stdin>'
   
       def __str__(self):
  
verification_info: {"golden_diff": "diff --git a/hy/lex/__init__.py b/hy/lex/__init__.py\n--- a/hy/lex/__init__.py\n+++ b/hy/lex/__init__.py\n@@ -34,7 +34,7 @@\n     except LexingError as e:\n         pos = e.getsourcepos()\n         raise LexException(\"Could not identify the next token.\",\n-                           pos.lineno, pos.colno)\n+                           pos.lineno, pos.colno, buf)\n     except LexException as e:\n         if e.source is None:\n             e.source = buf\ndiff --git a/hy/lex/exceptions.py b/hy/lex/exceptions.py\n--- a/hy/lex/exceptions.py\n+++ b/hy/lex/exceptions.py\n@@ -24,12 +24,12 @@\n \n class LexException(HyError):\n     \"\"\"Error during the Lexing of a Hython expression.\"\"\"\n-    def __init__(self, message, lineno, colno):\n+    def __init__(self, message, lineno, colno, source=None):\n         super(LexException, self).__init__(message)\n         self.message = message\n         self.lineno = lineno\n         self.colno = colno\n-        self.source = None\n+        self.source = source\n         self.filename = '<stdin>'\n \n     def __str__(self):\n", "issue": "Single quote crashes hy2py\n## x.hy\r\n\r\n```\r\n'\r\n```\r\n\r\n## `hy2py x.hy`\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"<string>\", line 1, in <module>\r\n  File \"hy/cmdline.py\", line 406, in hy2py_main\r\n    if stdin_text is None\r\n  File \"hy/cmdline.py\", line 186, in pretty_error\r\n    print(e, file=sys.stderr)\r\n  File \"hy/lex/exceptions.py\", line 43, in __str__\r\n    source = self.source.split(\"\\n\")\r\nAttributeError: 'NoneType' object has no attribute 'split'\r\n```\n", "before_files": [{"content": "# Copyright (c) 2013 Nicolas Dandrimont <nicolas.dandrimont@crans.org>\n# Copyright (c) 2013 Bob Tolbert <bob@tolbert.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.errors import HyError\n\n\nclass LexException(HyError):\n    \"\"\"Error during the Lexing of a Hython expression.\"\"\"\n    def __init__(self, message, lineno, colno):\n        super(LexException, self).__init__(message)\n        self.message = message\n        self.lineno = lineno\n        self.colno = colno\n        self.source = None\n        self.filename = '<stdin>'\n\n    def __str__(self):\n        from hy.errors import colored\n\n        line = self.lineno\n        start = self.colno\n\n        result = \"\"\n\n        source = self.source.split(\"\\n\")\n\n        if line > 0 and start > 0:\n            result += '  File \"%s\", line %d, column %d\\n\\n' % (self.filename,\n                                                               line,\n                                                               start)\n\n            if len(self.source) > 0:\n                source_line = source[line-1]\n            else:\n                source_line = \"\"\n\n            result += '  %s\\n' % colored.red(source_line)\n            result += '  %s%s\\n' % (' '*(start-1), colored.green('^'))\n\n        result += colored.yellow(\"LexException: %s\\n\\n\" % self.message)\n\n        return result\n\n\nclass PrematureEndOfInput(LexException):\n    \"\"\"We got a premature end of input\"\"\"\n    def __init__(self, message):\n        super(PrematureEndOfInput, self).__init__(message, -1, -1)\n", "path": "hy/lex/exceptions.py"}, {"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 rply.errors import LexingError\n\nfrom hy.lex.exceptions import LexException, PrematureEndOfInput  # NOQA\nfrom hy.lex.lexer import lexer\nfrom hy.lex.parser import parser\n\n\ndef tokenize(buf):\n    \"\"\"\n    Tokenize a Lisp file or string buffer into internal Hy objects.\n    \"\"\"\n    try:\n        return parser.parse(lexer.lex(buf))\n    except LexingError as e:\n        pos = e.getsourcepos()\n        raise LexException(\"Could not identify the next token.\",\n                           pos.lineno, pos.colno)\n    except LexException as e:\n        if e.source is None:\n            e.source = buf\n        raise\n", "path": "hy/lex/__init__.py"}], "after_files": [{"content": "# Copyright (c) 2013 Nicolas Dandrimont <nicolas.dandrimont@crans.org>\n# Copyright (c) 2013 Bob Tolbert <bob@tolbert.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.errors import HyError\n\n\nclass LexException(HyError):\n    \"\"\"Error during the Lexing of a Hython expression.\"\"\"\n    def __init__(self, message, lineno, colno, source=None):\n        super(LexException, self).__init__(message)\n        self.message = message\n        self.lineno = lineno\n        self.colno = colno\n        self.source = source\n        self.filename = '<stdin>'\n\n    def __str__(self):\n        from hy.errors import colored\n\n        line = self.lineno\n        start = self.colno\n\n        result = \"\"\n\n        source = self.source.split(\"\\n\")\n\n        if line > 0 and start > 0:\n            result += '  File \"%s\", line %d, column %d\\n\\n' % (self.filename,\n                                                               line,\n                                                               start)\n\n            if len(self.source) > 0:\n                source_line = source[line-1]\n            else:\n                source_line = \"\"\n\n            result += '  %s\\n' % colored.red(source_line)\n            result += '  %s%s\\n' % (' '*(start-1), colored.green('^'))\n\n        result += colored.yellow(\"LexException: %s\\n\\n\" % self.message)\n\n        return result\n\n\nclass PrematureEndOfInput(LexException):\n    \"\"\"We got a premature end of input\"\"\"\n    def __init__(self, message):\n        super(PrematureEndOfInput, self).__init__(message, -1, -1)\n", "path": "hy/lex/exceptions.py"}, {"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 rply.errors import LexingError\n\nfrom hy.lex.exceptions import LexException, PrematureEndOfInput  # NOQA\nfrom hy.lex.lexer import lexer\nfrom hy.lex.parser import parser\n\n\ndef tokenize(buf):\n    \"\"\"\n    Tokenize a Lisp file or string buffer into internal Hy objects.\n    \"\"\"\n    try:\n        return parser.parse(lexer.lex(buf))\n    except LexingError as e:\n        pos = e.getsourcepos()\n        raise LexException(\"Could not identify the next token.\",\n                           pos.lineno, pos.colno, buf)\n    except LexException as e:\n        if e.source is None:\n            e.source = buf\n        raise\n", "path": "hy/lex/__init__.py"}]}