# HG changeset patch # User Goffi # Date 1455301963 -3600 # Node ID 20fbca3c949af977996f68e9f3c2a609f2542069 # Parent e3e2effc9a4c1961edd145478629fa9b86031db3 server: fixed bad encoding handling in options parsing diff -r e3e2effc9a4c -r 20fbca3c949a src/twisted/plugins/libervia_server.py --- a/src/twisted/plugins/libervia_server.py Mon Jan 25 17:02:13 2016 +0100 +++ b/src/twisted/plugins/libervia_server.py Fri Feb 12 19:32:43 2016 +0100 @@ -70,12 +70,21 @@ def coerceConnectionType(value): # called from Libervia.OPT_PARAMETERS + if isinstance(value, unicode): + # XXX: if value comes from sat.conf, it's unicode, + # and we need byte str here (for twisted) + value = value.encode('utf-8') allowed_values = ('http', 'https', 'both') if value not in allowed_values: raise ValueError("%(given)s not in %(expected)s" % {'given': value, 'expected': str(allowed_values)}) return value def coerceDataDir(value): # called from Libervia.OPT_PARAMETERS + if isinstance(value, unicode): + # XXX: if value comes from sat.conf, it's unicode, + # and we need byte str here (for twisted) + value = value.encode('utf-8') + value = value.encode('utf-8') html = os.path.join(value, C.HTML_DIR) if not os.path.isfile(os.path.join(html, C.LIBERVIA_MAIN_PAGE)): raise ValueError("%s is not a Libervia's browser HTML directory" % os.path.realpath(html))