From bb360781b0c24655dcef3f4fbf559168875cc1cb Mon Sep 17 00:00:00 2001 From: Alexander Kozlovsky Date: Thu, 2 Dec 2021 11:49:39 +0100 Subject: [PATCH] Decode api_key if gui_settings return it as bytes --- src/tribler-gui/tribler_gui/tribler_window.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tribler-gui/tribler_gui/tribler_window.py b/src/tribler-gui/tribler_gui/tribler_window.py index 11b0937fe7d..d7f710b099a 100644 --- a/src/tribler-gui/tribler_gui/tribler_window.py +++ b/src/tribler-gui/tribler_gui/tribler_window.py @@ -148,6 +148,9 @@ def __init__( self.gui_settings = settings api_port = api_port or int(get_gui_setting(self.gui_settings, "api_port", DEFAULT_API_PORT)) api_key = api_key or get_gui_setting(self.gui_settings, "api_key", hexlify(os.urandom(16))) + if isinstance(api_key, bytes): + # in QSettings, api_key can be stored as bytes, then we decode it to str + api_key = api_key.decode('ascii') self.gui_settings.setValue("api_key", api_key) api_port = NetworkUtils().get_first_free_port(start=api_port)