prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  unicode literrals
  based on irc discussion with @rjarry  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `master/buildbot/util/lineboundaries.py`
  Content:
  ```
  1 # This file is part of Buildbot.  Buildbot is free software: you can
  2 # redistribute it and/or modify it under the terms of the GNU General Public
  3 # License as published by the Free Software Foundation, version 2.
  4 #
  5 # This program is distributed in the hope that it will be useful, but WITHOUT
  6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  7 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  8 # details.
  9 #
  10 # You should have received a copy of the GNU General Public License along with
  11 # this program; if not, write to the Free Software Foundation, Inc., 51
  12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  13 #
  14 # Copyright Buildbot Team Members
  15 
  16 from twisted.internet import defer
  17 
  18 
  19 class LineBoundaryFinder(object):
  20 
  21     __slots__ = ['partialLine', 'callback']
  22 
  23     def __init__(self, callback):
  24         self.partialLine = None
  25         self.callback = callback
  26 
  27     def append(self, text):
  28         if self.partialLine:
  29             text = self.partialLine + text
  30             self.partialLine = None
  31         if text:
  32             if text[-1] != '\n':
  33                 i = text.rfind('\n')
  34                 if i >= 0:
  35                     i = i + 1
  36                     text, self.partialLine = text[:i], text[i:]
  37                 else:
  38                     self.partialLine = text
  39                     return defer.succeed(None)
  40             return self.callback(text)
  41 
  42     def flush(self):
  43         if self.partialLine:
  44             return self.append('\n')
  45         else:
  46             return defer.succeed(None)
  47
  ```
  --- 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/master/buildbot/util/lineboundaries.py b/master/buildbot/util/lineboundaries.py
  --- a/master/buildbot/util/lineboundaries.py
  +++ b/master/buildbot/util/lineboundaries.py
  @@ -13,6 +13,8 @@
   #
   # Copyright Buildbot Team Members
   
  +import re
  +
   from twisted.internet import defer
   
   
  @@ -20,6 +22,10 @@
   
       __slots__ = ['partialLine', 'callback']
   
  +    # the lookahead here (`(?=.)`) ensures that `\r` doesn't match at the end
  +    # of the buffer
  +    newline_re = re.compile(r'(\r\n|\r(?=.)|\n)')
  +
       def __init__(self, callback):
           self.partialLine = None
           self.callback = callback
  @@ -28,6 +34,7 @@
           if self.partialLine:
               text = self.partialLine + text
               self.partialLine = None
  +        text = self.newline_re.sub('\n', text)
           if text:
               if text[-1] != '\n':
                   i = text.rfind('\n')
  
verification_info: {"golden_diff": "diff --git a/master/buildbot/util/lineboundaries.py b/master/buildbot/util/lineboundaries.py\n--- a/master/buildbot/util/lineboundaries.py\n+++ b/master/buildbot/util/lineboundaries.py\n@@ -13,6 +13,8 @@\n #\n # Copyright Buildbot Team Members\n \n+import re\n+\n from twisted.internet import defer\n \n \n@@ -20,6 +22,10 @@\n \n     __slots__ = ['partialLine', 'callback']\n \n+    # the lookahead here (`(?=.)`) ensures that `\\r` doesn't match at the end\n+    # of the buffer\n+    newline_re = re.compile(r'(\\r\\n|\\r(?=.)|\\n)')\n+\n     def __init__(self, callback):\n         self.partialLine = None\n         self.callback = callback\n@@ -28,6 +34,7 @@\n         if self.partialLine:\n             text = self.partialLine + text\n             self.partialLine = None\n+        text = self.newline_re.sub('\\n', text)\n         if text:\n             if text[-1] != '\\n':\n                 i = text.rfind('\\n')\n", "issue": "unicode literrals\nbased on irc discussion with @rjarry  \n", "before_files": [{"content": "# This file is part of Buildbot.  Buildbot is free software: you can\n# redistribute it and/or modify it under the terms of the GNU General Public\n# License as published by the Free Software Foundation, version 2.\n#\n# This program is distributed in the hope that it will be useful, but WITHOUT\n# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\n# details.\n#\n# You should have received a copy of the GNU General Public License along with\n# this program; if not, write to the Free Software Foundation, Inc., 51\n# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n#\n# Copyright Buildbot Team Members\n\nfrom twisted.internet import defer\n\n\nclass LineBoundaryFinder(object):\n\n    __slots__ = ['partialLine', 'callback']\n\n    def __init__(self, callback):\n        self.partialLine = None\n        self.callback = callback\n\n    def append(self, text):\n        if self.partialLine:\n            text = self.partialLine + text\n            self.partialLine = None\n        if text:\n            if text[-1] != '\\n':\n                i = text.rfind('\\n')\n                if i >= 0:\n                    i = i + 1\n                    text, self.partialLine = text[:i], text[i:]\n                else:\n                    self.partialLine = text\n                    return defer.succeed(None)\n            return self.callback(text)\n\n    def flush(self):\n        if self.partialLine:\n            return self.append('\\n')\n        else:\n            return defer.succeed(None)\n", "path": "master/buildbot/util/lineboundaries.py"}], "after_files": [{"content": "# This file is part of Buildbot.  Buildbot is free software: you can\n# redistribute it and/or modify it under the terms of the GNU General Public\n# License as published by the Free Software Foundation, version 2.\n#\n# This program is distributed in the hope that it will be useful, but WITHOUT\n# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\n# details.\n#\n# You should have received a copy of the GNU General Public License along with\n# this program; if not, write to the Free Software Foundation, Inc., 51\n# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n#\n# Copyright Buildbot Team Members\n\nimport re\n\nfrom twisted.internet import defer\n\n\nclass LineBoundaryFinder(object):\n\n    __slots__ = ['partialLine', 'callback']\n\n    # the lookahead here (`(?=.)`) ensures that `\\r` doesn't match at the end\n    # of the buffer\n    newline_re = re.compile(r'(\\r\\n|\\r(?=.)|\\n)')\n\n    def __init__(self, callback):\n        self.partialLine = None\n        self.callback = callback\n\n    def append(self, text):\n        if self.partialLine:\n            text = self.partialLine + text\n            self.partialLine = None\n        text = self.newline_re.sub('\\n', text)\n        if text:\n            if text[-1] != '\\n':\n                i = text.rfind('\\n')\n                if i >= 0:\n                    i = i + 1\n                    text, self.partialLine = text[:i], text[i:]\n                else:\n                    self.partialLine = text\n                    return defer.succeed(None)\n            return self.callback(text)\n\n    def flush(self):\n        if self.partialLine:\n            return self.append('\\n')\n        else:\n            return defer.succeed(None)\n", "path": "master/buildbot/util/lineboundaries.py"}]}