prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  pep2rss disregards PEPs written in reStructuredText format
  This can be seen at https://www.python.org/dev/peps/peps.rss/ where the last (most recent) RSS entry is the last PEP written in plaintext.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pep2rss.py`
  Content:
  ```
  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 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/pep2rss.py b/pep2rss.py
  --- a/pep2rss.py
  +++ b/pep2rss.py
  @@ -15,8 +15,10 @@
               return line[len(text):].strip()
       return None
   
  -# get list of peps with creation time (from "Created:" string in pep .txt)
  +# get list of peps with creation time
  +# (from "Created:" string in pep .rst or .txt)
   peps = glob.glob('pep-*.txt')
  +peps.extend(glob.glob('pep-*.rst'))
   def pep_creation_dt(full_path):
       created_str = firstline_startingwith(full_path, 'Created:')
       # bleh, I was hoping to avoid re but some PEPs editorialize
  
verification_info: {"golden_diff": "diff --git a/pep2rss.py b/pep2rss.py\n--- a/pep2rss.py\n+++ b/pep2rss.py\n@@ -15,8 +15,10 @@\n             return line[len(text):].strip()\n     return None\n \n-# get list of peps with creation time (from \"Created:\" string in pep .txt)\n+# get list of peps with creation time\n+# (from \"Created:\" string in pep .rst or .txt)\n peps = glob.glob('pep-*.txt')\n+peps.extend(glob.glob('pep-*.rst'))\n def 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", "issue": "pep2rss disregards PEPs written in reStructuredText format\nThis can be seen at https://www.python.org/dev/peps/peps.rss/ where the last (most recent) RSS entry is the last PEP written in plaintext.\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"}], "after_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\n# (from \"Created:\" string in pep .rst or .txt)\npeps = glob.glob('pep-*.txt')\npeps.extend(glob.glob('pep-*.rst'))\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"}]}