From 8e618b93838eba8e51eeac15016c98eb0e77a01f Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 16 Oct 2020 11:25:29 -0400 Subject: [PATCH] Fix Python 2 issue. --- src/allmydata/node.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 9f5375885..852c8889d 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -9,7 +9,7 @@ import os.path import re import types import errno -from io import StringIO +from io import StringIO, BytesIO import tempfile from base64 import b32decode, b32encode @@ -209,7 +209,10 @@ def config_from_string(basedir, portnumfile, config_str, _valid_config=None): # load configuration from in-memory string parser = configparser.SafeConfigParser() - parser.readfp(StringIO(config_str)) + if PY2: + parser.readfp(BytesIO(config_str.encode("utf-8"))) + else: + parser.readfp(StringIO(config_str)) fname = "" configutil.validate_config(fname, parser, _valid_config)