prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  unicode literrals
  based on irc discussion with @rjarry  
  
  </issue>
  <code>
  [start of master/buildbot/util/lineboundaries.py]
  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 of master/buildbot/util/lineboundaries.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
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"}]}