# Buggy code
def _create_engine(self):
    log.info(
        "using the connect string {0!s}".format(
            censor_connect_string(self.connect_string)
        )
    )
    try:
        log.debug(
            "using pool_size={0!s}, pool_timeout={1!s}, pool_recycle={2!s}".format(
                self.pool_size, self.pool_timeout, self.pool_recycle
            )
        )
        engine = create_engine(
            self.connect_string,
            encoding=self.encoding,
            convert_unicode=False,
            pool_size=self.pool_size,
            pool_recycle=self.pool_recycle,
            pool_timeout=self.pool_timeout,
        )
    except TypeError:
        # The DB Engine/Poolclass might not support the pool_size.
        log.debug("connecting without pool_size.")
        engine = create_engine(
            self.connect_string, encoding=self.encoding, convert_unicode=False
        )
    return engine


# Traceback (UnicodeDecodeError)
[2018-08-14 14:49:53,123] ERROR in app: Exception on /system/documentation [GET]
Traceback (most recent call last):
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/fred/privacyidea/privacyidea/privacyidea/api/lib/prepolicy.py", line 120, in policy_wrapper
return wrapped_function(*args, **kwds)
File "/home/fred/privacyidea/privacyidea/privacyidea/api/auth.py", line 316, in decorated_function
return f(*args, **kwargs)
File "/home/fred/privacyidea/privacyidea/privacyidea/api/system.py", line 113, in get_config_documentation
context=context))
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/flask/templating.py", line 135, in render_template
context, ctx.app)
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/flask/templating.py", line 117, in _render
rv = template.render(context)
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/home/fred/privacyidea/privacyidea/venv/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/fred/privacyidea/privacyidea/privacyidea/static/templates/documentation.rst", line 56, in top-level template code
{{k}}: **{{v}}**
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128)

# Fixed code
def _create_engine(self):
    log.info(
        "using the connect string {0!s}".format(
            censor_connect_string(self.connect_string)
        )
    )
    try:
        log.debug(
            "using pool_size={0!s}, pool_timeout={1!s}, pool_recycle={2!s}".format(
                self.pool_size, self.pool_timeout, self.pool_recycle
            )
        )
        engine = create_engine(
            self.connect_string,
            encoding=self.encoding,
            convert_unicode=False,
            pool_size=self.pool_size,
            pool_recycle=self.pool_recycle,
            pool_timeout=self.pool_timeout,
        )
    except TypeError:
        # The DB Engine/Poolclass might not support the pool_size.
        log.debug("connecting without pool_size.")
        engine = create_engine(
            self.connect_string, encoding=self.encoding, convert_unicode=False
        )
    return engine