prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  utf8 decoding error
  ### Description
  Context is not correctly displayed due to utf8 decoding error.
  
  Traceback (most recent call last):
    File "/home/carstein/Tools/pwndbg/pwndbg/commands/__init__.py", line 109, in __call__
      return self.function(*args, **kwargs)
    File "/home/carstein/Tools/pwndbg/pwndbg/commands/__init__.py", line 200, in _OnlyWhenRunning
      return function(*a, **kw)
    File "/home/carstein/Tools/pwndbg/pwndbg/commands/context.py", line 86, in context
      result.extend(func())
    File "/home/carstein/Tools/pwndbg/pwndbg/commands/context.py", line 98, in context_regs
      return [pwndbg.ui.banner("registers")] + get_regs()
    File "/home/carstein/Tools/pwndbg/pwndbg/ui.py", line 52, in banner
      banner = ljust_colored(banner, width, str(config.banner_separator))
    File "/home/carstein/Tools/pwndbg/pwndbg/color/__init__.py", line 77, in ljust_colored
      return x + ((remaining // len(char) + 1) * char)[:remaining]
  UnicodeDecodeError: 'utf8' codec can't decode byte 0xe2 in position 105: unexpected end of data
  
  
  ### Steps to reproduce
  1. Load binary into gdb
  2. `break main`
  3. `run`
  
  
  ### My setup
  pwndbg version: 
  Gdb:      GNU gdb (GDB) 8.1
  Python:   2.7.13 (default, Nov 24 2017, 17:33:09)  [GCC 6.3.0 20170516]
  Pwndbg:   1.0.0 build: 869e832
  Capstone: 4.0.1024
  Unicorn:  1.0.1
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pwndbg/color/__init__.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 from __future__ import absolute_import
  4 from __future__ import division
  5 from __future__ import print_function
  6 from __future__ import unicode_literals
  7 
  8 import re
  9 
  10 import pwndbg.memoize
  11 
  12 NORMAL         = "\x1b[0m"
  13 BLACK          = "\x1b[30m"
  14 RED            = "\x1b[31m"
  15 GREEN          = "\x1b[32m"
  16 YELLOW         = "\x1b[33m"
  17 BLUE           = "\x1b[34m"
  18 PURPLE         = "\x1b[35m"
  19 CYAN           = "\x1b[36m"
  20 LIGHT_GREY = LIGHT_GRAY = "\x1b[37m"
  21 FOREGROUND     = "\x1b[39m"
  22 GREY = GRAY    = "\x1b[90m"
  23 LIGHT_RED      = "\x1b[91m"
  24 LIGHT_GREEN    = "\x1b[92m"
  25 LIGHT_YELLOW   = "\x1b[93m"
  26 LIGHT_BLUE     = "\x1b[94m"
  27 LIGHT_PURPLE   = "\x1b[95m"
  28 LIGHT_CYAN     = "\x1b[96m"
  29 WHITE          = "\x1b[97m"
  30 BOLD           = "\x1b[1m"
  31 UNDERLINE      = "\x1b[4m"
  32 
  33 def none(x): return str(x)
  34 def normal(x): return colorize(x, NORMAL)
  35 def black(x): return colorize(x, BLACK)
  36 def red(x): return colorize(x, RED)
  37 def green(x): return colorize(x, GREEN)
  38 def yellow(x): return colorize(x, YELLOW)
  39 def blue(x): return colorize(x, BLUE)
  40 def purple(x): return colorize(x, PURPLE)
  41 def cyan(x): return colorize(x, CYAN)
  42 def light_gray(x): return colorize(x, LIGHT_GRAY)
  43 def foreground(x): return colorize(x, FOREGROUND)
  44 def gray(x): return colorize(x, GRAY)
  45 def light_red(x): return colorize(x, LIGHT_RED)
  46 def light_green(x): return colorize(x, LIGHT_GREEN)
  47 def light_yellow(x): return colorize(x, LIGHT_YELLOW)
  48 def light_blue(x): return colorize(x, LIGHT_BLUE)
  49 def light_purple(x): return colorize(x, LIGHT_PURPLE)
  50 def light_cyan(x): return colorize(x, LIGHT_CYAN)
  51 def white(x): return colorize(x, WHITE)
  52 def bold(x): return colorize(x, BOLD)
  53 def underline(x): return colorize(x, UNDERLINE)
  54 def colorize(x, color): return color + terminateWith(str(x), color) + NORMAL
  55 
  56 @pwndbg.memoize.reset_on_stop
  57 def generateColorFunctionInner(old, new):
  58     def wrapper(text):
  59         return new(old(text))
  60     return wrapper
  61 
  62 def generateColorFunction(config):
  63     function = lambda x: x
  64     for color in str(config).split(','):
  65         function = generateColorFunctionInner(function, globals()[color.lower().replace('-', '_')])
  66     return function
  67 
  68 def strip(x):
  69     return re.sub('\x1b\\[\d+m', '', x)
  70 
  71 def terminateWith(x, color):
  72     return re.sub('\x1b\\[0m', NORMAL + color, x)
  73 
  74 def ljust_colored(x, length, char=' '):
  75     remaining = length - len(strip(x))
  76     return x + ((remaining // len(char) + 1) * char)[:remaining]
  77 
  78 def rjust_colored(x, length, char=' '):
  79     remaining = length - len(strip(x))
  80     return ((remaining // len(char) + 1) * char)[:remaining] + x
  81
  ```
  --- 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/pwndbg/color/__init__.py b/pwndbg/color/__init__.py
  --- a/pwndbg/color/__init__.py
  +++ b/pwndbg/color/__init__.py
  @@ -7,6 +7,8 @@
   
   import re
   
  +import six
  +
   import pwndbg.memoize
   
   NORMAL         = "\x1b[0m"
  @@ -72,9 +74,17 @@
       return re.sub('\x1b\\[0m', NORMAL + color, x)
   
   def ljust_colored(x, length, char=' '):
  +    # TODO: workaround until issue #404
  +    if six.PY2:
  +        x = x if isinstance(x, six.text_type) else x.decode('utf8')
  +        char = char if isinstance(char, six.text_type) else char.decode('utf8')
       remaining = length - len(strip(x))
       return x + ((remaining // len(char) + 1) * char)[:remaining]
   
   def rjust_colored(x, length, char=' '):
  +    # TODO: workaround until issue #404
  +    if six.PY2:
  +        x = x if isinstance(x, six.text_type) else x.decode('utf8')
  +        char = char if isinstance(char, six.text_type) else char.decode('utf8')
       remaining = length - len(strip(x))
       return ((remaining // len(char) + 1) * char)[:remaining] + x
  
verification_info: {"golden_diff": "diff --git a/pwndbg/color/__init__.py b/pwndbg/color/__init__.py\n--- a/pwndbg/color/__init__.py\n+++ b/pwndbg/color/__init__.py\n@@ -7,6 +7,8 @@\n \n import re\n \n+import six\n+\n import pwndbg.memoize\n \n NORMAL         = \"\\x1b[0m\"\n@@ -72,9 +74,17 @@\n     return re.sub('\\x1b\\\\[0m', NORMAL + color, x)\n \n def ljust_colored(x, length, char=' '):\n+    # TODO: workaround until issue #404\n+    if six.PY2:\n+        x = x if isinstance(x, six.text_type) else x.decode('utf8')\n+        char = char if isinstance(char, six.text_type) else char.decode('utf8')\n     remaining = length - len(strip(x))\n     return x + ((remaining // len(char) + 1) * char)[:remaining]\n \n def rjust_colored(x, length, char=' '):\n+    # TODO: workaround until issue #404\n+    if six.PY2:\n+        x = x if isinstance(x, six.text_type) else x.decode('utf8')\n+        char = char if isinstance(char, six.text_type) else char.decode('utf8')\n     remaining = length - len(strip(x))\n     return ((remaining // len(char) + 1) * char)[:remaining] + x\n", "issue": "utf8 decoding error\n### Description\r\nContext is not correctly displayed due to utf8 decoding error.\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/carstein/Tools/pwndbg/pwndbg/commands/__init__.py\", line 109, in __call__\r\n    return self.function(*args, **kwargs)\r\n  File \"/home/carstein/Tools/pwndbg/pwndbg/commands/__init__.py\", line 200, in _OnlyWhenRunning\r\n    return function(*a, **kw)\r\n  File \"/home/carstein/Tools/pwndbg/pwndbg/commands/context.py\", line 86, in context\r\n    result.extend(func())\r\n  File \"/home/carstein/Tools/pwndbg/pwndbg/commands/context.py\", line 98, in context_regs\r\n    return [pwndbg.ui.banner(\"registers\")] + get_regs()\r\n  File \"/home/carstein/Tools/pwndbg/pwndbg/ui.py\", line 52, in banner\r\n    banner = ljust_colored(banner, width, str(config.banner_separator))\r\n  File \"/home/carstein/Tools/pwndbg/pwndbg/color/__init__.py\", line 77, in ljust_colored\r\n    return x + ((remaining // len(char) + 1) * char)[:remaining]\r\nUnicodeDecodeError: 'utf8' codec can't decode byte 0xe2 in position 105: unexpected end of data\r\n\r\n\r\n### Steps to reproduce\r\n1. Load binary into gdb\r\n2. `break main`\r\n3. `run`\r\n\r\n\r\n### My setup\r\npwndbg version: \r\nGdb:      GNU gdb (GDB) 8.1\r\nPython:   2.7.13 (default, Nov 24 2017, 17:33:09)  [GCC 6.3.0 20170516]\r\nPwndbg:   1.0.0 build: 869e832\r\nCapstone: 4.0.1024\r\nUnicorn:  1.0.1\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nimport re\n\nimport pwndbg.memoize\n\nNORMAL         = \"\\x1b[0m\"\nBLACK          = \"\\x1b[30m\"\nRED            = \"\\x1b[31m\"\nGREEN          = \"\\x1b[32m\"\nYELLOW         = \"\\x1b[33m\"\nBLUE           = \"\\x1b[34m\"\nPURPLE         = \"\\x1b[35m\"\nCYAN           = \"\\x1b[36m\"\nLIGHT_GREY = LIGHT_GRAY = \"\\x1b[37m\"\nFOREGROUND     = \"\\x1b[39m\"\nGREY = GRAY    = \"\\x1b[90m\"\nLIGHT_RED      = \"\\x1b[91m\"\nLIGHT_GREEN    = \"\\x1b[92m\"\nLIGHT_YELLOW   = \"\\x1b[93m\"\nLIGHT_BLUE     = \"\\x1b[94m\"\nLIGHT_PURPLE   = \"\\x1b[95m\"\nLIGHT_CYAN     = \"\\x1b[96m\"\nWHITE          = \"\\x1b[97m\"\nBOLD           = \"\\x1b[1m\"\nUNDERLINE      = \"\\x1b[4m\"\n\ndef none(x): return str(x)\ndef normal(x): return colorize(x, NORMAL)\ndef black(x): return colorize(x, BLACK)\ndef red(x): return colorize(x, RED)\ndef green(x): return colorize(x, GREEN)\ndef yellow(x): return colorize(x, YELLOW)\ndef blue(x): return colorize(x, BLUE)\ndef purple(x): return colorize(x, PURPLE)\ndef cyan(x): return colorize(x, CYAN)\ndef light_gray(x): return colorize(x, LIGHT_GRAY)\ndef foreground(x): return colorize(x, FOREGROUND)\ndef gray(x): return colorize(x, GRAY)\ndef light_red(x): return colorize(x, LIGHT_RED)\ndef light_green(x): return colorize(x, LIGHT_GREEN)\ndef light_yellow(x): return colorize(x, LIGHT_YELLOW)\ndef light_blue(x): return colorize(x, LIGHT_BLUE)\ndef light_purple(x): return colorize(x, LIGHT_PURPLE)\ndef light_cyan(x): return colorize(x, LIGHT_CYAN)\ndef white(x): return colorize(x, WHITE)\ndef bold(x): return colorize(x, BOLD)\ndef underline(x): return colorize(x, UNDERLINE)\ndef colorize(x, color): return color + terminateWith(str(x), color) + NORMAL\n\n@pwndbg.memoize.reset_on_stop\ndef generateColorFunctionInner(old, new):\n    def wrapper(text):\n        return new(old(text))\n    return wrapper\n\ndef generateColorFunction(config):\n    function = lambda x: x\n    for color in str(config).split(','):\n        function = generateColorFunctionInner(function, globals()[color.lower().replace('-', '_')])\n    return function\n\ndef strip(x):\n    return re.sub('\\x1b\\\\[\\d+m', '', x)\n\ndef terminateWith(x, color):\n    return re.sub('\\x1b\\\\[0m', NORMAL + color, x)\n\ndef ljust_colored(x, length, char=' '):\n    remaining = length - len(strip(x))\n    return x + ((remaining // len(char) + 1) * char)[:remaining]\n\ndef rjust_colored(x, length, char=' '):\n    remaining = length - len(strip(x))\n    return ((remaining // len(char) + 1) * char)[:remaining] + x\n", "path": "pwndbg/color/__init__.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nimport re\n\nimport six\n\nimport pwndbg.memoize\n\nNORMAL         = \"\\x1b[0m\"\nBLACK          = \"\\x1b[30m\"\nRED            = \"\\x1b[31m\"\nGREEN          = \"\\x1b[32m\"\nYELLOW         = \"\\x1b[33m\"\nBLUE           = \"\\x1b[34m\"\nPURPLE         = \"\\x1b[35m\"\nCYAN           = \"\\x1b[36m\"\nLIGHT_GREY = LIGHT_GRAY = \"\\x1b[37m\"\nFOREGROUND     = \"\\x1b[39m\"\nGREY = GRAY    = \"\\x1b[90m\"\nLIGHT_RED      = \"\\x1b[91m\"\nLIGHT_GREEN    = \"\\x1b[92m\"\nLIGHT_YELLOW   = \"\\x1b[93m\"\nLIGHT_BLUE     = \"\\x1b[94m\"\nLIGHT_PURPLE   = \"\\x1b[95m\"\nLIGHT_CYAN     = \"\\x1b[96m\"\nWHITE          = \"\\x1b[97m\"\nBOLD           = \"\\x1b[1m\"\nUNDERLINE      = \"\\x1b[4m\"\n\ndef none(x): return str(x)\ndef normal(x): return colorize(x, NORMAL)\ndef black(x): return colorize(x, BLACK)\ndef red(x): return colorize(x, RED)\ndef green(x): return colorize(x, GREEN)\ndef yellow(x): return colorize(x, YELLOW)\ndef blue(x): return colorize(x, BLUE)\ndef purple(x): return colorize(x, PURPLE)\ndef cyan(x): return colorize(x, CYAN)\ndef light_gray(x): return colorize(x, LIGHT_GRAY)\ndef foreground(x): return colorize(x, FOREGROUND)\ndef gray(x): return colorize(x, GRAY)\ndef light_red(x): return colorize(x, LIGHT_RED)\ndef light_green(x): return colorize(x, LIGHT_GREEN)\ndef light_yellow(x): return colorize(x, LIGHT_YELLOW)\ndef light_blue(x): return colorize(x, LIGHT_BLUE)\ndef light_purple(x): return colorize(x, LIGHT_PURPLE)\ndef light_cyan(x): return colorize(x, LIGHT_CYAN)\ndef white(x): return colorize(x, WHITE)\ndef bold(x): return colorize(x, BOLD)\ndef underline(x): return colorize(x, UNDERLINE)\ndef colorize(x, color): return color + terminateWith(str(x), color) + NORMAL\n\n@pwndbg.memoize.reset_on_stop\ndef generateColorFunctionInner(old, new):\n    def wrapper(text):\n        return new(old(text))\n    return wrapper\n\ndef generateColorFunction(config):\n    function = lambda x: x\n    for color in str(config).split(','):\n        function = generateColorFunctionInner(function, globals()[color.lower().replace('-', '_')])\n    return function\n\ndef strip(x):\n    return re.sub('\\x1b\\\\[\\d+m', '', x)\n\ndef terminateWith(x, color):\n    return re.sub('\\x1b\\\\[0m', NORMAL + color, x)\n\ndef ljust_colored(x, length, char=' '):\n    # TODO: workaround until issue #404\n    if six.PY2:\n        x = x if isinstance(x, six.text_type) else x.decode('utf8')\n        char = char if isinstance(char, six.text_type) else char.decode('utf8')\n    remaining = length - len(strip(x))\n    return x + ((remaining // len(char) + 1) * char)[:remaining]\n\ndef rjust_colored(x, length, char=' '):\n    # TODO: workaround until issue #404\n    if six.PY2:\n        x = x if isinstance(x, six.text_type) else x.decode('utf8')\n        char = char if isinstance(char, six.text_type) else char.decode('utf8')\n    remaining = length - len(strip(x))\n    return ((remaining // len(char) + 1) * char)[:remaining] + x\n", "path": "pwndbg/color/__init__.py"}]}