prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Runtime error (BrokenPipeError) helpers.py line 11
  When restarting i3 using `i3 restart`, error bar pops up with message `py3status: Runtime error (BrokenPipeError) helpers.py line 11. Please try to fix this and reload i3wm (Mod+Shift+R)`
  
  Everything appears to be functioning and the bar still shows.
  
  Running Ubuntu 16.04
  py3status 3.1
  python 3.5.2
  
  
  </issue>
  <code>
  [start of py3status/__init__.py]
  1 import locale
  2 import sys
  3 
  4 from py3status.core import Py3statusWrapper
  5 
  6 try:
  7     from setproctitle import setproctitle
  8     setproctitle('py3status')
  9 except ImportError:
  10     pass
  11 
  12 
  13 def main():
  14     try:
  15         locale.setlocale(locale.LC_ALL, '')
  16     except locale.Error:
  17         print('No locale available')
  18         sys.exit(2)
  19 
  20     py3 = None
  21     try:
  22         py3 = Py3statusWrapper()
  23         py3.setup()
  24     except KeyboardInterrupt:
  25         if py3:
  26             py3.notify_user('Setup interrupted (KeyboardInterrupt).')
  27         sys.exit(0)
  28     except Exception as e:
  29         if py3:
  30             py3.report_exception('Setup error')
  31         else:
  32             # we cannot report this Exception
  33             raise e
  34         sys.exit(2)
  35 
  36     try:
  37         py3.run()
  38     except Exception:
  39         py3.report_exception('Runtime error')
  40         sys.exit(3)
  41     except KeyboardInterrupt:
  42         pass
  43     finally:
  44         py3.stop()
  45         sys.exit(0)
  46 
  47 
  48 if __name__ == '__main__':
  49     main()
  50
  [end of py3status/__init__.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/py3status/__init__.py b/py3status/__init__.py
  --- a/py3status/__init__.py
  +++ b/py3status/__init__.py
  @@ -9,6 +9,13 @@
   except ImportError:
       pass
   
  +try:
  +    # python3
  +    IOPipeError = BrokenPipeError
  +except NameError:
  +    # python2
  +    IOPipeError = IOError
  +
   
   def main():
       try:
  @@ -21,9 +28,9 @@
       try:
           py3 = Py3statusWrapper()
           py3.setup()
  -    except KeyboardInterrupt:
  +    except (IOPipeError, KeyboardInterrupt):
           if py3:
  -            py3.notify_user('Setup interrupted (KeyboardInterrupt).')
  +            py3.notify_user('Setup interrupted')
           sys.exit(0)
       except Exception as e:
           if py3:
  @@ -35,11 +42,11 @@
   
       try:
           py3.run()
  +    except (IOPipeError, KeyboardInterrupt):
  +        pass
       except Exception:
           py3.report_exception('Runtime error')
           sys.exit(3)
  -    except KeyboardInterrupt:
  -        pass
       finally:
           py3.stop()
           sys.exit(0)
  
verification_info: {"golden_diff": "diff --git a/py3status/__init__.py b/py3status/__init__.py\n--- a/py3status/__init__.py\n+++ b/py3status/__init__.py\n@@ -9,6 +9,13 @@\n except ImportError:\n     pass\n \n+try:\n+    # python3\n+    IOPipeError = BrokenPipeError\n+except NameError:\n+    # python2\n+    IOPipeError = IOError\n+\n \n def main():\n     try:\n@@ -21,9 +28,9 @@\n     try:\n         py3 = Py3statusWrapper()\n         py3.setup()\n-    except KeyboardInterrupt:\n+    except (IOPipeError, KeyboardInterrupt):\n         if py3:\n-            py3.notify_user('Setup interrupted (KeyboardInterrupt).')\n+            py3.notify_user('Setup interrupted')\n         sys.exit(0)\n     except Exception as e:\n         if py3:\n@@ -35,11 +42,11 @@\n \n     try:\n         py3.run()\n+    except (IOPipeError, KeyboardInterrupt):\n+        pass\n     except Exception:\n         py3.report_exception('Runtime error')\n         sys.exit(3)\n-    except KeyboardInterrupt:\n-        pass\n     finally:\n         py3.stop()\n         sys.exit(0)\n", "issue": "Runtime error (BrokenPipeError) helpers.py line 11\nWhen restarting i3 using `i3 restart`, error bar pops up with message `py3status: Runtime error (BrokenPipeError) helpers.py line 11. Please try to fix this and reload i3wm (Mod+Shift+R)`\n\nEverything appears to be functioning and the bar still shows.\n\nRunning Ubuntu 16.04\npy3status 3.1\npython 3.5.2\n\n", "before_files": [{"content": "import locale\nimport sys\n\nfrom py3status.core import Py3statusWrapper\n\ntry:\n    from setproctitle import setproctitle\n    setproctitle('py3status')\nexcept ImportError:\n    pass\n\n\ndef main():\n    try:\n        locale.setlocale(locale.LC_ALL, '')\n    except locale.Error:\n        print('No locale available')\n        sys.exit(2)\n\n    py3 = None\n    try:\n        py3 = Py3statusWrapper()\n        py3.setup()\n    except KeyboardInterrupt:\n        if py3:\n            py3.notify_user('Setup interrupted (KeyboardInterrupt).')\n        sys.exit(0)\n    except Exception as e:\n        if py3:\n            py3.report_exception('Setup error')\n        else:\n            # we cannot report this Exception\n            raise e\n        sys.exit(2)\n\n    try:\n        py3.run()\n    except Exception:\n        py3.report_exception('Runtime error')\n        sys.exit(3)\n    except KeyboardInterrupt:\n        pass\n    finally:\n        py3.stop()\n        sys.exit(0)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "py3status/__init__.py"}]}