Page MenuHomePhabricator

[electrum] suppress an error when sys.stdout is None
ClosedPublic

Authored by PiRK on Jun 12 2024, 10:13.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABC4bdc3dd0a0ae: [electrum] suppress an error when sys.stdout is None
Summary

This removes an error dialog that can pop up on Windows when the application is executed without anny stdout attached: "Unhandled execption in script... AtrributeError: 'NoneType' object has no attribute 'write'"

Context: This error was encountered by a Windows user when trying to open Electrum ABC while it was already running. In such a case the application prints "ok" (the return value of server.gui(config_options) to stdout. Luckily this error does not happen in a "normal" scenario (Electrum ABC started only once) every time the gui application is about to be closed , because the print call is preceded by sys.exit(0) . See the electrum-abc::run_gui function

Test Plan
diff --git a/electrum/electrum-abc b/electrum/electrum-abc
index 9703327c24..ea6e340888 100755
--- a/electrum/electrum-abc
+++ b/electrum/electrum-abc
@@ -398,6 +398,8 @@ def run_gui(config: SimpleConfig, config_options: dict):
             daemon_thread.join(timeout=5.0)
         sys.exit(0)

+    sys.stdout = None
+
     return server.gui(config_options)

With this patch, check that before this diff the error can be reproduced by starting the application in two terminals (python stacktrace printed to the second terminal). After this diff there is no error.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
about_dialog
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 29287
Build 58110: Build Diffelectrum-tests
Build 58109: arc lint + arc unit