prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  pep2rss can raise UnicodeEncodeError on certain platforms
  This is due to the default encoding of [`open()`](https://docs.python.org/3/library/functions.html#open) being platform dependent.
  
  For example, on Windows (CP-1252), it can raise
  `UnicodeEncodeError: 'charmap' codec can't encode character '\u0141' in position 1545: character maps to <undefined>`
  when handling the character, 'Ł', in the name of the author of [PEP 569](https://www.python.org/dev/peps/pep-0569/).
  https://github.com/python/peps/blob/433faca4cf1bb8a0550d01b86b2b4581b3eda460/pep-0569.rst#L5
  
  </issue>
  <code>
  [start of pep2rss.py]
  1 #!/usr/bin/env python
  2 
  3 # usage: pep-hook.py $REPOS $REV
  4 # (standard post-commit args)
  5 
  6 import os, glob, time, datetime, stat, re, sys
  7 import codecs
  8 import PyRSS2Gen as rssgen
  9 
  10 RSS_PATH = os.path.join(sys.argv[1], 'peps.rss')
  11 
  12 def firstline_startingwith(full_path, text):
  13     for line in codecs.open(full_path, encoding="utf-8"):
  14         if line.startswith(text):
  15             return line[len(text):].strip()
  16     return None
  17 
  18 # get list of peps with creation time (from "Created:" string in pep .txt)
  19 peps = glob.glob('pep-*.txt')
  20 def pep_creation_dt(full_path):
  21     created_str = firstline_startingwith(full_path, 'Created:')
  22     # bleh, I was hoping to avoid re but some PEPs editorialize
  23     # on the Created line
  24     m = re.search(r'''(\d+-\w+-\d{4})''', created_str)
  25     if not m:
  26         # some older ones have an empty line, that's okay, if it's old
  27         # we ipso facto don't care about it.
  28         # "return None" would make the most sense but datetime objects
  29         # refuse to compare with that. :-|
  30         return datetime.datetime(*time.localtime(0)[:6])
  31     created_str = m.group(1)
  32     try:
  33         t = time.strptime(created_str, '%d-%b-%Y')
  34     except ValueError:
  35         t = time.strptime(created_str, '%d-%B-%Y')
  36     return datetime.datetime(*t[:6])
  37 peps_with_dt = [(pep_creation_dt(full_path), full_path) for full_path in peps]
  38 # sort peps by date, newest first
  39 peps_with_dt.sort(reverse=True)
  40 
  41 # generate rss items for 10 most recent peps
  42 items = []
  43 for dt, full_path in peps_with_dt[:10]:
  44     try:
  45         n = int(full_path.split('-')[-1].split('.')[0])
  46     except ValueError:
  47         pass
  48     title = firstline_startingwith(full_path, 'Title:')
  49     author = firstline_startingwith(full_path, 'Author:')
  50     url = 'http://www.python.org/dev/peps/pep-%0.4d' % n
  51     item = rssgen.RSSItem(
  52         title = 'PEP %d: %s' % (n, title),
  53         link = url,
  54         description = 'Author: %s' % author,
  55         guid = rssgen.Guid(url),
  56         pubDate = dt)
  57     items.append(item)
  58 
  59 # the rss envelope
  60 desc = """
  61 Newest Python Enhancement Proposals (PEPs) - Information on new
  62 language features, and some meta-information like release
  63 procedure and schedules
  64 """.strip()
  65 rss = rssgen.RSS2(
  66     title = 'Newest Python PEPs',
  67     link = 'http://www.python.org/dev/peps',
  68     description = desc,
  69     lastBuildDate = datetime.datetime.now(),
  70     items = items)
  71 
  72 with open(RSS_PATH, 'w') as fp:
  73     fp.write(rss.to_xml())
  74
  [end of pep2rss.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/pep2rss.py b/pep2rss.py
  --- a/pep2rss.py
  +++ b/pep2rss.py
  @@ -1,16 +1,15 @@
  -#!/usr/bin/env python
  +#!/usr/bin/env python3
   
   # usage: pep-hook.py $REPOS $REV
   # (standard post-commit args)
   
   import os, glob, time, datetime, stat, re, sys
  -import codecs
   import PyRSS2Gen as rssgen
   
   RSS_PATH = os.path.join(sys.argv[1], 'peps.rss')
   
   def firstline_startingwith(full_path, text):
  -    for line in codecs.open(full_path, encoding="utf-8"):
  +    for line in open(full_path, encoding="utf-8"):
           if line.startswith(text):
               return line[len(text):].strip()
       return None
  @@ -69,5 +68,5 @@
       lastBuildDate = datetime.datetime.now(),
       items = items)
   
  -with open(RSS_PATH, 'w') as fp:
  -    fp.write(rss.to_xml())
  +with open(RSS_PATH, 'w', encoding="utf-8") as fp:
  +    fp.write(rss.to_xml(encoding="utf-8"))
  
verification_info: {"golden_diff": "diff --git a/pep2rss.py b/pep2rss.py\n--- a/pep2rss.py\n+++ b/pep2rss.py\n@@ -1,16 +1,15 @@\n-#!/usr/bin/env python\n+#!/usr/bin/env python3\n \n # usage: pep-hook.py $REPOS $REV\n # (standard post-commit args)\n \n import os, glob, time, datetime, stat, re, sys\n-import codecs\n import PyRSS2Gen as rssgen\n \n RSS_PATH = os.path.join(sys.argv[1], 'peps.rss')\n \n def firstline_startingwith(full_path, text):\n-    for line in codecs.open(full_path, encoding=\"utf-8\"):\n+    for line in open(full_path, encoding=\"utf-8\"):\n         if line.startswith(text):\n             return line[len(text):].strip()\n     return None\n@@ -69,5 +68,5 @@\n     lastBuildDate = datetime.datetime.now(),\n     items = items)\n \n-with open(RSS_PATH, 'w') as fp:\n-    fp.write(rss.to_xml())\n+with open(RSS_PATH, 'w', encoding=\"utf-8\") as fp:\n+    fp.write(rss.to_xml(encoding=\"utf-8\"))\n", "issue": "pep2rss can raise UnicodeEncodeError on certain platforms\nThis is due to the default encoding of [`open()`](https://docs.python.org/3/library/functions.html#open) being platform dependent.\r\n\r\nFor example, on Windows (CP-1252), it can raise\r\n`UnicodeEncodeError: 'charmap' codec can't encode character '\\u0141' in position 1545: character maps to <undefined>`\r\nwhen handling the character, '\u0141', in the name of the author of [PEP 569](https://www.python.org/dev/peps/pep-0569/).\r\nhttps://github.com/python/peps/blob/433faca4cf1bb8a0550d01b86b2b4581b3eda460/pep-0569.rst#L5\n", "before_files": [{"content": "#!/usr/bin/env python\n\n# usage: pep-hook.py $REPOS $REV\n# (standard post-commit args)\n\nimport os, glob, time, datetime, stat, re, sys\nimport codecs\nimport PyRSS2Gen as rssgen\n\nRSS_PATH = os.path.join(sys.argv[1], 'peps.rss')\n\ndef firstline_startingwith(full_path, text):\n    for line in codecs.open(full_path, encoding=\"utf-8\"):\n        if line.startswith(text):\n            return line[len(text):].strip()\n    return None\n\n# get list of peps with creation time (from \"Created:\" string in pep .txt)\npeps = glob.glob('pep-*.txt')\ndef pep_creation_dt(full_path):\n    created_str = firstline_startingwith(full_path, 'Created:')\n    # bleh, I was hoping to avoid re but some PEPs editorialize\n    # on the Created line\n    m = re.search(r'''(\\d+-\\w+-\\d{4})''', created_str)\n    if not m:\n        # some older ones have an empty line, that's okay, if it's old\n        # we ipso facto don't care about it.\n        # \"return None\" would make the most sense but datetime objects\n        # refuse to compare with that. :-|\n        return datetime.datetime(*time.localtime(0)[:6])\n    created_str = m.group(1)\n    try:\n        t = time.strptime(created_str, '%d-%b-%Y')\n    except ValueError:\n        t = time.strptime(created_str, '%d-%B-%Y')\n    return datetime.datetime(*t[:6])\npeps_with_dt = [(pep_creation_dt(full_path), full_path) for full_path in peps]\n# sort peps by date, newest first\npeps_with_dt.sort(reverse=True)\n\n# generate rss items for 10 most recent peps\nitems = []\nfor dt, full_path in peps_with_dt[:10]:\n    try:\n        n = int(full_path.split('-')[-1].split('.')[0])\n    except ValueError:\n        pass\n    title = firstline_startingwith(full_path, 'Title:')\n    author = firstline_startingwith(full_path, 'Author:')\n    url = 'http://www.python.org/dev/peps/pep-%0.4d' % n\n    item = rssgen.RSSItem(\n        title = 'PEP %d: %s' % (n, title),\n        link = url,\n        description = 'Author: %s' % author,\n        guid = rssgen.Guid(url),\n        pubDate = dt)\n    items.append(item)\n\n# the rss envelope\ndesc = \"\"\"\nNewest Python Enhancement Proposals (PEPs) - Information on new\nlanguage features, and some meta-information like release\nprocedure and schedules\n\"\"\".strip()\nrss = rssgen.RSS2(\n    title = 'Newest Python PEPs',\n    link = 'http://www.python.org/dev/peps',\n    description = desc,\n    lastBuildDate = datetime.datetime.now(),\n    items = items)\n\nwith open(RSS_PATH, 'w') as fp:\n    fp.write(rss.to_xml())\n", "path": "pep2rss.py"}]}