From ba735bf1a2c19dc853e2732f83409452c869c652 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Mon, 28 Sep 2020 09:54:32 +0300 Subject: [PATCH] Try to fix issue #177 . See: https://github.com/shlomif/PySolFC/issues/177 - custom game wizard failure due to bytestring vs. unicode string. Thanks to @Neelix57 and @Butterfly for the report and some investigation. --- pysollib/wizardutil.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pysollib/wizardutil.py b/pysollib/wizardutil.py index 1fdb9000..1a558ec0 100644 --- a/pysollib/wizardutil.py +++ b/pysollib/wizardutil.py @@ -429,11 +429,17 @@ class MyCustomGame(CustomGame): # escape v = v.replace('\\', '\\\\') v = v.replace("'", "\\'") - if isinstance(v, six.text_type): - v = v.encode('utf-8') + v = v.replace("\n", "\\n") + v = v.replace("\r", "\\r") + v = v.replace("\t", "\\t") + # See: https://github.com/shlomif/PySolFC/issues/177 + DISABLE_DUE_TO_GH177 = False + if DISABLE_DUE_TO_GH177: + if isinstance(v, six.text_type): + v = v.encode('utf-8') if not v: v = 'Invalid Game Name' - fd.write(" '%s': '%s',\n" % (w.var_name, v)) + fd.write(" '{}': '{}',\n".format(w.var_name, v)) fd.write(" 'gameid': %i,\n" % gameid) fd.write('''\