We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
codec can't encode characters in position 29-36
### Before submitting your issue:

Enable debug logging in Medusa settings, reproduce the error (be sure to disable after the bug is fixed)

**Branch/Commit:** feature/add-indexerids-to-db/4bdbd81
**OS:** windows
**What you did:** Started up medusa while having the series `Tokyo Goul` added. With scene exceptions added from xem.
**What happened:** The error below showed.
**What you expected:** no error.
**Logs:**
```
2017-12-27 21:29:34 ERROR    MAIN :: [4bdbd81] BraceMessage string formatting failed. Using representation instead.
  File "D:\JetBrains\PyCharm 2017.2.4\helpers\pydev\pydevd.py", line 1599, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:\JetBrains\PyCharm 2017.2.4\helpers\pydev\pydevd.py", line 1026, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:/Development/Medusa5/start.py", line 7, in <module>
    main()
  File "D:/Development/Medusa5\medusa\__main__.py", line 2109, in main
    application.start(sys.argv[1:])
  File "D:/Development/Medusa5\medusa\__main__.py", line 354, in start
    name_cache.build_name_cache()
  File "D:/Development/Medusa5\medusa\name_cache.py", line 128, in build_name_cache
    _cache_name(show)
  File "D:/Development/Medusa5\medusa\name_cache.py", line 116, in _cache_name
    'names': ', '.join(names.keys())
  File "D:/Development/Medusa5\medusa\logger\adapters\style.py", line 89, in log
    self.logger.log(level, brace_msg, **kwargs)
  File "D:\Python27\lib\logging\__init__.py", line 1489, in log
    self.logger.log(level, msg, *args, **kwargs)
  File "D:\Python27\lib\logging\__init__.py", line 1231, in log
    self._log(level, msg, args, **kwargs)
  File "D:\Python27\lib\logging\__init__.py", line 1286, in _log
    self.handle(record)
  File "D:\Python27\lib\logging\__init__.py", line 1296, in handle
    self.callHandlers(record)
  File "D:\Python27\lib\logging\__init__.py", line 1336, in callHandlers
    hdlr.handle(record)
  File "D:\Python27\lib\logging\__init__.py", line 759, in handle
    self.emit(record)
  File "D:\Python27\lib\logging\handlers.py", line 78, in emit
    logging.FileHandler.emit(self, record)
  File "D:\Python27\lib\logging\__init__.py", line 957, in emit
    StreamHandler.emit(self, record)
  File "D:\Python27\lib\logging\__init__.py", line 861, in emit
    msg = self.format(record)
  File "D:\Python27\lib\logging\__init__.py", line 734, in format
    return fmt.format(record)
  File "D:/Development/Medusa5\medusa\logger\__init__.py", line 546, in format
    msg = super(CensoredFormatter, self).format(record)
  File "D:\Python27\lib\logging\__init__.py", line 465, in format
    record.message = record.getMessage()
  File "D:\Python27\lib\logging\__init__.py", line 325, in getMessage
    msg = str(self.msg)
  File "D:/Development/Medusa5\medusa\init\logconfig.py", line 80, in __str__
    result = text_type(self.fmt)
  File "D:/Development/Medusa5\medusa\logger\adapters\style.py", line 49, in __str__
    ''.join(traceback.format_stack()),
Traceback (most recent call last):
  File "D:/Development/Medusa5\medusa\logger\adapters\style.py", line 39, in __str__
    return msg.format(*args, **kwargs)
  File "D:\Python27\lib\encodings\cp1252.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 29-36: character maps to <undefined>
```

I got it in my branch, but I doubt it was because of any of the changed I did.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `medusa/logger/adapters/style.py`
Content:
```
1 # coding=utf-8
2 
3 """Style Adapters for Python logging."""
4 
5 from __future__ import unicode_literals
6 
7 import collections
8 import functools
9 import logging
10 import traceback
11 
12 from six import text_type
13 
14 log = logging.getLogger(__name__)
15 log.addHandler(logging.NullHandler())
16 
17 
18 class BraceMessage(object):
19     """Lazily convert a Brace-formatted message."""
20 
21     def __init__(self, msg, *args, **kwargs):
22         """Initialize a lazy-formatted message."""
23         self.msg = msg
24         self.args = args
25         self.kwargs = kwargs
26 
27     def __str__(self):
28         """Convert to string."""
29         args = self.args
30         kwargs = self.kwargs
31         if args and len(args) == 1:
32             if args[0] and isinstance(args[0], collections.Mapping):
33                 args = []
34                 kwargs = self.args[0]
35 
36         msg = str(self.msg)
37 
38         try:
39             return msg.format(*args, **kwargs)
40         except IndexError:
41             try:
42                 return msg.format(kwargs)
43             except IndexError:
44                 return msg
45         except Exception:
46             log.error(
47                 'BraceMessage string formatting failed. '
48                 'Using representation instead.\n{0}'.format(
49                     ''.join(traceback.format_stack()),
50                 )
51             )
52             return repr(self)
53 
54     def __repr__(self):
55         """Convert to class representation."""
56         sep = ', '
57         kw_repr = '{key}={value!r}'
58         name = self.__class__.__name__
59         args = sep.join(map(text_type, self.args))
60         kwargs = sep.join(kw_repr.format(key=k, value=v)
61                           for k, v in self.kwargs.items())
62         return '{cls}({args})'.format(
63             cls=name,
64             args=sep.join([repr(self.msg), args, kwargs])
65         )
66 
67     def format(self, *args, **kwargs):
68         """Format a BraceMessage string."""
69         return str(self).format(*args, **kwargs)
70 
71 
72 class BraceAdapter(logging.LoggerAdapter):
73     """Adapt logger to use Brace-formatted messages."""
74 
75     def __init__(self, logger, extra=None):
76         """Initialize the Brace adapter with a logger."""
77         super(BraceAdapter, self).__init__(logger, extra)
78         self.debug = functools.partial(self.log, logging.DEBUG)
79         self.info = functools.partial(self.log, logging.INFO)
80         self.warning = functools.partial(self.log, logging.WARNING)
81         self.error = functools.partial(self.log, logging.ERROR)
82         self.critical = functools.partial(self.log, logging.CRITICAL)
83 
84     def log(self, level, msg, *args, **kwargs):
85         """Log a message at the specified level using Brace-formatting."""
86         if self.isEnabledFor(level):
87             msg, kwargs = self.process(msg, kwargs)
88             brace_msg = BraceMessage(msg, *args, **kwargs)
89             self.logger.log(level, brace_msg, **kwargs)
90 
91     def exception(self, msg, *args, **kwargs):
92         """Add exception information before delegating to self.log."""
93         kwargs['exc_info'] = 1
94         self.log(logging.ERROR, msg, *args, **kwargs)
95
```
--- 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()

```

diff --git a/medusa/logger/adapters/style.py b/medusa/logger/adapters/style.py
--- a/medusa/logger/adapters/style.py
+++ b/medusa/logger/adapters/style.py
@@ -33,7 +33,7 @@
                 args = []
                 kwargs = self.args[0]
 
-        msg = str(self.msg)
+        msg = text_type(self.msg)
 
         try:
             return msg.format(*args, **kwargs)

{"golden_diff": "diff --git a/medusa/logger/adapters/style.py b/medusa/logger/adapters/style.py\n--- a/medusa/logger/adapters/style.py\n+++ b/medusa/logger/adapters/style.py\n@@ -33,7 +33,7 @@\n                 args = []\n                 kwargs = self.args[0]\n \n-        msg = str(self.msg)\n+        msg = text_type(self.msg)\n \n         try:\n             return msg.format(*args, **kwargs)\n", "issue": "codec can't encode characters in position 29-36\n### Before submitting your issue:\r\n\r\nEnable debug logging in Medusa settings, reproduce the error (be sure to disable after the bug is fixed)\r\n\r\n**Branch/Commit:** feature/add-indexerids-to-db/4bdbd81\r\n**OS:** windows\r\n**What you did:** Started up medusa while having the series `Tokyo Goul` added. With scene exceptions added from xem.\r\n**What happened:** The error below showed.\r\n**What you expected:** no error.\r\n**Logs:**\r\n```\r\n2017-12-27 21:29:34 ERROR    MAIN :: [4bdbd81] BraceMessage string formatting failed. Using representation instead.\r\n  File \"D:\\JetBrains\\PyCharm 2017.2.4\\helpers\\pydev\\pydevd.py\", line 1599, in <module>\r\n    globals = debugger.run(setup['file'], None, None, is_module)\r\n  File \"D:\\JetBrains\\PyCharm 2017.2.4\\helpers\\pydev\\pydevd.py\", line 1026, in run\r\n    pydev_imports.execfile(file, globals, locals)  # execute the script\r\n  File \"D:/Development/Medusa5/start.py\", line 7, in <module>\r\n    main()\r\n  File \"D:/Development/Medusa5\\medusa\\__main__.py\", line 2109, in main\r\n    application.start(sys.argv[1:])\r\n  File \"D:/Development/Medusa5\\medusa\\__main__.py\", line 354, in start\r\n    name_cache.build_name_cache()\r\n  File \"D:/Development/Medusa5\\medusa\\name_cache.py\", line 128, in build_name_cache\r\n    _cache_name(show)\r\n  File \"D:/Development/Medusa5\\medusa\\name_cache.py\", line 116, in _cache_name\r\n    'names': ', '.join(names.keys())\r\n  File \"D:/Development/Medusa5\\medusa\\logger\\adapters\\style.py\", line 89, in log\r\n    self.logger.log(level, brace_msg, **kwargs)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 1489, in log\r\n    self.logger.log(level, msg, *args, **kwargs)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 1231, in log\r\n    self._log(level, msg, args, **kwargs)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 1286, in _log\r\n    self.handle(record)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 1296, in handle\r\n    self.callHandlers(record)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 1336, in callHandlers\r\n    hdlr.handle(record)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 759, in handle\r\n    self.emit(record)\r\n  File \"D:\\Python27\\lib\\logging\\handlers.py\", line 78, in emit\r\n    logging.FileHandler.emit(self, record)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 957, in emit\r\n    StreamHandler.emit(self, record)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 861, in emit\r\n    msg = self.format(record)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 734, in format\r\n    return fmt.format(record)\r\n  File \"D:/Development/Medusa5\\medusa\\logger\\__init__.py\", line 546, in format\r\n    msg = super(CensoredFormatter, self).format(record)\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 465, in format\r\n    record.message = record.getMessage()\r\n  File \"D:\\Python27\\lib\\logging\\__init__.py\", line 325, in getMessage\r\n    msg = str(self.msg)\r\n  File \"D:/Development/Medusa5\\medusa\\init\\logconfig.py\", line 80, in __str__\r\n    result = text_type(self.fmt)\r\n  File \"D:/Development/Medusa5\\medusa\\logger\\adapters\\style.py\", line 49, in __str__\r\n    ''.join(traceback.format_stack()),\r\nTraceback (most recent call last):\r\n  File \"D:/Development/Medusa5\\medusa\\logger\\adapters\\style.py\", line 39, in __str__\r\n    return msg.format(*args, **kwargs)\r\n  File \"D:\\Python27\\lib\\encodings\\cp1252.py\", line 12, in encode\r\n    return codecs.charmap_encode(input,errors,encoding_table)\r\nUnicodeEncodeError: 'charmap' codec can't encode characters in position 29-36: character maps to <undefined>\r\n```\r\n\r\nI got it in my branch, but I doubt it was because of any of the changed I did.\n", "before_files": [{"content": "# coding=utf-8\n\n\"\"\"Style Adapters for Python logging.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport collections\nimport functools\nimport logging\nimport traceback\n\nfrom six import text_type\n\nlog = logging.getLogger(__name__)\nlog.addHandler(logging.NullHandler())\n\n\nclass BraceMessage(object):\n    \"\"\"Lazily convert a Brace-formatted message.\"\"\"\n\n    def __init__(self, msg, *args, **kwargs):\n        \"\"\"Initialize a lazy-formatted message.\"\"\"\n        self.msg = msg\n        self.args = args\n        self.kwargs = kwargs\n\n    def __str__(self):\n        \"\"\"Convert to string.\"\"\"\n        args = self.args\n        kwargs = self.kwargs\n        if args and len(args) == 1:\n            if args[0] and isinstance(args[0], collections.Mapping):\n                args = []\n                kwargs = self.args[0]\n\n        msg = str(self.msg)\n\n        try:\n            return msg.format(*args, **kwargs)\n        except IndexError:\n            try:\n                return msg.format(kwargs)\n            except IndexError:\n                return msg\n        except Exception:\n            log.error(\n                'BraceMessage string formatting failed. '\n                'Using representation instead.\\n{0}'.format(\n                    ''.join(traceback.format_stack()),\n                )\n            )\n            return repr(self)\n\n    def __repr__(self):\n        \"\"\"Convert to class representation.\"\"\"\n        sep = ', '\n        kw_repr = '{key}={value!r}'\n        name = self.__class__.__name__\n        args = sep.join(map(text_type, self.args))\n        kwargs = sep.join(kw_repr.format(key=k, value=v)\n                          for k, v in self.kwargs.items())\n        return '{cls}({args})'.format(\n            cls=name,\n            args=sep.join([repr(self.msg), args, kwargs])\n        )\n\n    def format(self, *args, **kwargs):\n        \"\"\"Format a BraceMessage string.\"\"\"\n        return str(self).format(*args, **kwargs)\n\n\nclass BraceAdapter(logging.LoggerAdapter):\n    \"\"\"Adapt logger to use Brace-formatted messages.\"\"\"\n\n    def __init__(self, logger, extra=None):\n        \"\"\"Initialize the Brace adapter with a logger.\"\"\"\n        super(BraceAdapter, self).__init__(logger, extra)\n        self.debug = functools.partial(self.log, logging.DEBUG)\n        self.info = functools.partial(self.log, logging.INFO)\n        self.warning = functools.partial(self.log, logging.WARNING)\n        self.error = functools.partial(self.log, logging.ERROR)\n        self.critical = functools.partial(self.log, logging.CRITICAL)\n\n    def log(self, level, msg, *args, **kwargs):\n        \"\"\"Log a message at the specified level using Brace-formatting.\"\"\"\n        if self.isEnabledFor(level):\n            msg, kwargs = self.process(msg, kwargs)\n            brace_msg = BraceMessage(msg, *args, **kwargs)\n            self.logger.log(level, brace_msg, **kwargs)\n\n    def exception(self, msg, *args, **kwargs):\n        \"\"\"Add exception information before delegating to self.log.\"\"\"\n        kwargs['exc_info'] = 1\n        self.log(logging.ERROR, msg, *args, **kwargs)\n", "path": "medusa/logger/adapters/style.py"}], "after_files": [{"content": "# coding=utf-8\n\n\"\"\"Style Adapters for Python logging.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport collections\nimport functools\nimport logging\nimport traceback\n\nfrom six import text_type\n\nlog = logging.getLogger(__name__)\nlog.addHandler(logging.NullHandler())\n\n\nclass BraceMessage(object):\n    \"\"\"Lazily convert a Brace-formatted message.\"\"\"\n\n    def __init__(self, msg, *args, **kwargs):\n        \"\"\"Initialize a lazy-formatted message.\"\"\"\n        self.msg = msg\n        self.args = args\n        self.kwargs = kwargs\n\n    def __str__(self):\n        \"\"\"Convert to string.\"\"\"\n        args = self.args\n        kwargs = self.kwargs\n        if args and len(args) == 1:\n            if args[0] and isinstance(args[0], collections.Mapping):\n                args = []\n                kwargs = self.args[0]\n\n        msg = text_type(self.msg)\n\n        try:\n            return msg.format(*args, **kwargs)\n        except IndexError:\n            try:\n                return msg.format(kwargs)\n            except IndexError:\n                return msg\n        except Exception:\n            log.error(\n                'BraceMessage string formatting failed. '\n                'Using representation instead.\\n{0}'.format(\n                    ''.join(traceback.format_stack()),\n                )\n            )\n            return repr(self)\n\n    def __repr__(self):\n        \"\"\"Convert to class representation.\"\"\"\n        sep = ', '\n        kw_repr = '{key}={value!r}'\n        name = self.__class__.__name__\n        args = sep.join(map(text_type, self.args))\n        kwargs = sep.join(kw_repr.format(key=k, value=v)\n                          for k, v in self.kwargs.items())\n        return '{cls}({args})'.format(\n            cls=name,\n            args=sep.join([repr(self.msg), args, kwargs])\n        )\n\n    def format(self, *args, **kwargs):\n        \"\"\"Format a BraceMessage string.\"\"\"\n        return str(self).format(*args, **kwargs)\n\n\nclass BraceAdapter(logging.LoggerAdapter):\n    \"\"\"Adapt logger to use Brace-formatted messages.\"\"\"\n\n    def __init__(self, logger, extra=None):\n        \"\"\"Initialize the Brace adapter with a logger.\"\"\"\n        super(BraceAdapter, self).__init__(logger, extra)\n        self.debug = functools.partial(self.log, logging.DEBUG)\n        self.info = functools.partial(self.log, logging.INFO)\n        self.warning = functools.partial(self.log, logging.WARNING)\n        self.error = functools.partial(self.log, logging.ERROR)\n        self.critical = functools.partial(self.log, logging.CRITICAL)\n\n    def log(self, level, msg, *args, **kwargs):\n        \"\"\"Log a message at the specified level using Brace-formatting.\"\"\"\n        if self.isEnabledFor(level):\n            msg, kwargs = self.process(msg, kwargs)\n            brace_msg = BraceMessage(msg, *args, **kwargs)\n            self.logger.log(level, brace_msg, **kwargs)\n\n    def exception(self, msg, *args, **kwargs):\n        \"\"\"Add exception information before delegating to self.log.\"\"\"\n        kwargs['exc_info'] = 1\n        self.log(logging.ERROR, msg, *args, **kwargs)\n", "path": "medusa/logger/adapters/style.py"}]}