commands: print warnings to stderr so output is still valid json
What changed, and why it matters
This commit changes three internal warning messages so they are printed to the error stream instead of the normal output stream. The goal is to keep Electrum's command-line JSON output clean and valid when these warnings appear. It is a minor reliability/usability fix, not a security patch.
No security action needed. Treat as a normal code-quality or UX improvement.
Security signals we found
No security-relevant code changed
No input validation changes
No cryptographic or wallet logic changes
Output stream hygiene fix only
Evidence from the diff
In electrum/commands.py, three print() calls that emit developer-facing warnings about undocumented arguments or unknown types are redirected to sys.stderr. This prevents the warnings from corrupting JSON-formatted stdout produced by CLI commands. There is no change to logic, parsing, validation, or cryptographic handling.
Changed components
electrum/commands.pyCLI argument parser generation (get_parser)Inspect captured patch +3 / −3
diff --git a/electrum/commands.py b/electrum/commands.py
index 217f5ab..03aef89 100644
--- a/electrum/commands.py
+++ b/electrum/commands.py
@@ -2469,7 +2469,7 @@ def get_parser():
continue
help = cmd.arg_descriptions.get(optname)
if not help:
- print(f'undocumented argument {cmdname}::{optname}')
+ print(f'undocumented argument {cmdname}::{optname}', file=sys.stderr)
action = "store_true" if default is False else 'store'
if action == 'store':
type_descriptor = cmd.arg_types.get(optname)
@@ -2484,11 +2484,11 @@ def get_parser():
continue
help = cmd.arg_descriptions.get(param)
if not help:
- print(f'undocumented argument {cmdname}::{param}')
+ print(f'undocumented argument {cmdname}::{param}', file=sys.stderr)
type_descriptor = cmd.arg_types.get(param)
_type = arg_types.get(type_descriptor)
if help is not None and _type is None:
- print(f'unknown type \'{_type}\' for {cmdname}::{param}')
+ print(f'unknown type \'{_type}\' for {cmdname}::{param}', file=sys.stderr)
p.add_argument(param, help=help, type=_type)
cvh = config_variables.get(cmdname)
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.