prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Bpython
  Hi,
  
  Unfortunately pwntools doesn't seem to work with bpython 0.12 in conjunction of python 2.7.9.
  
  from pwn import *
  
  results in:
  
  Traceback (most recent call last):
    File "<input>", line 1, in <module>
    File "/usr/local/lib/python2.7/dist-packages/pwn/**init**.py", line 2, in <module>
      from .toplevel import *
    File "/usr/local/lib/python2.7/dist-packages/pwn/toplevel.py", line 2, in <module>
      from pwnlib                  import *
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/**init**.py", line 10, in <module>
      from . import \
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/asm.py", line 45, in <module>
      from . import log
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/log.py", line 69, in <module>
      from .term      import spinners, text
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/**init**.py", line 1, in <module>
      from . import key, readline, text, termcap, keymap, term
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/readline.py", line 2, in <module>
      from . import term, text
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/text.py", line 111, in <module>
      sys.modules[**name**] = Module()
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/text.py", line 22, in **init**
      self.num_colors = termcap.get('colors', default = 8)
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/termcap.py", line 15, in get
      init()
    File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/termcap.py", line 39, in init
      curses.setupterm()
  TypeError: argument must be an int, or have a fileno() method.
  
  
  </issue>
  <code>
  [start of pwnlib/term/termcap.py]
  1 __all__ = ['get']
  2 import os, curses
  3 
  4 cache = None
  5 def get(cap, *args, **kwargs):
  6     default = kwargs.pop('default', '')
  7 
  8     if 'PWNLIB_NOTERM' in os.environ:
  9         return ''
  10 
  11     if kwargs != {}:
  12         raise TypeError("get(): No such argument %r" % kwargs.popitem()[0])
  13 
  14     if cache == None:
  15         init()
  16     s = cache.get(cap)
  17     if not s:
  18         s = curses.tigetstr(cap)
  19         if s == None:
  20             s = curses.tigetnum(cap)
  21             if s == -2:
  22                 s = curses.tigetflag(cap)
  23                 if s == -1:
  24                     # default to empty string so tparm doesn't fail
  25                     s = ''
  26                 else:
  27                     s = bool(s)
  28         cache[cap] = s
  29     # if `s' is not set `curses.tparm' will throw an error if given arguments
  30     if args and s:
  31         return curses.tparm(s, *args)
  32     else:
  33         return s
  34 
  35 def init():
  36     global cache
  37 
  38     if 'PWNLIB_NOTERM' not in os.environ:
  39         curses.setupterm()
  40 
  41     cache = {}
  42
  [end of pwnlib/term/termcap.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/pwnlib/term/termcap.py b/pwnlib/term/termcap.py
  --- a/pwnlib/term/termcap.py
  +++ b/pwnlib/term/termcap.py
  @@ -36,6 +36,10 @@
       global cache
   
       if 'PWNLIB_NOTERM' not in os.environ:
  -        curses.setupterm()
  +        # Fix for BPython
  +        try:
  +            curses.setupterm()
  +        except:
  +            pass
   
       cache = {}
  
verification_info: {"golden_diff": "diff --git a/pwnlib/term/termcap.py b/pwnlib/term/termcap.py\n--- a/pwnlib/term/termcap.py\n+++ b/pwnlib/term/termcap.py\n@@ -36,6 +36,10 @@\n     global cache\n \n     if 'PWNLIB_NOTERM' not in os.environ:\n-        curses.setupterm()\n+        # Fix for BPython\n+        try:\n+            curses.setupterm()\n+        except:\n+            pass\n \n     cache = {}\n", "issue": "Bpython\nHi,\n\nUnfortunately pwntools doesn't seem to work with bpython 0.12 in conjunction of python 2.7.9.\n\nfrom pwn import *\n\nresults in:\n\nTraceback (most recent call last):\n  File \"<input>\", line 1, in <module>\n  File \"/usr/local/lib/python2.7/dist-packages/pwn/**init**.py\", line 2, in <module>\n    from .toplevel import *\n  File \"/usr/local/lib/python2.7/dist-packages/pwn/toplevel.py\", line 2, in <module>\n    from pwnlib                  import *\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/**init**.py\", line 10, in <module>\n    from . import \\\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/asm.py\", line 45, in <module>\n    from . import log\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/log.py\", line 69, in <module>\n    from .term      import spinners, text\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/term/**init**.py\", line 1, in <module>\n    from . import key, readline, text, termcap, keymap, term\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/term/readline.py\", line 2, in <module>\n    from . import term, text\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/term/text.py\", line 111, in <module>\n    sys.modules[**name**] = Module()\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/term/text.py\", line 22, in **init**\n    self.num_colors = termcap.get('colors', default = 8)\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/term/termcap.py\", line 15, in get\n    init()\n  File \"/usr/local/lib/python2.7/dist-packages/pwnlib/term/termcap.py\", line 39, in init\n    curses.setupterm()\nTypeError: argument must be an int, or have a fileno() method.\n\n", "before_files": [{"content": "__all__ = ['get']\nimport os, curses\n\ncache = None\ndef get(cap, *args, **kwargs):\n    default = kwargs.pop('default', '')\n\n    if 'PWNLIB_NOTERM' in os.environ:\n        return ''\n\n    if kwargs != {}:\n        raise TypeError(\"get(): No such argument %r\" % kwargs.popitem()[0])\n\n    if cache == None:\n        init()\n    s = cache.get(cap)\n    if not s:\n        s = curses.tigetstr(cap)\n        if s == None:\n            s = curses.tigetnum(cap)\n            if s == -2:\n                s = curses.tigetflag(cap)\n                if s == -1:\n                    # default to empty string so tparm doesn't fail\n                    s = ''\n                else:\n                    s = bool(s)\n        cache[cap] = s\n    # if `s' is not set `curses.tparm' will throw an error if given arguments\n    if args and s:\n        return curses.tparm(s, *args)\n    else:\n        return s\n\ndef init():\n    global cache\n\n    if 'PWNLIB_NOTERM' not in os.environ:\n        curses.setupterm()\n\n    cache = {}\n", "path": "pwnlib/term/termcap.py"}]}