contrib: override system locale in gen-manpages.py
What changed, and why it matters
This is a developer tooling fix for a Python script that generates manual pages for Bitcoin Core. The script was failing on non-English systems because bitcoin-qt's version and help output was translated, causing an assertion to fail. The fix forces English output by adding --lang=en. It does not change any user-facing code, network behavior, or wallet handling.
No security action required. This is a benign build/development tooling fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies contrib/devtools/gen-manpages.py to pass –lang=en to bitcoin-qt invocations for –version and –help. This prevents localized strings from breaking a ‘Copyright (C)’ assertion and from producing diffs in generated man pages. The change is purely in the man-page generation tooling and does not alter binary behavior, consensus code, or command-line option handling.
Changed components
contrib/devtools/gen-manpages.pyInspect captured patch +19 / −5
diff --git a/contrib/devtools/gen-manpages.py b/contrib/devtools/gen-manpages.py
index 94187944..c5ec7309 100755
--- a/contrib/devtools/gen-manpages.py
+++ b/contrib/devtools/gen-manpages.py
@@ -50,8 +50,13 @@ mandir = os.getenv('MANDIR', os.path.join(topdir, 'doc/man'))
versions = []
for relpath in BINARIES:
abspath = os.path.join(builddir, relpath)
+ # Prevent QT from emitting a localized version string for --version and --help
+ is_qt = relpath == "bin/bitcoin-qt"
try:
- r = subprocess.run([abspath, "--version"], stdout=subprocess.PIPE, check=True, text=True)
+ cmd_args = ["--version"]
+ if is_qt:
+ cmd_args.append("--lang=en")
+ r = subprocess.run([abspath, *cmd_args], stdout=subprocess.PIPE, check=True, text=True)
except IOError:
if(args.skip_missing_binaries):
print(f'{abspath} not found or not an executable. Skipping...', file=sys.stderr)
@@ -69,13 +74,13 @@ for relpath in BINARIES:
copyright = r.stdout.split('\n')[1:]
assert copyright[0].startswith('Copyright (C)')
- versions.append((abspath, verstr, copyright))
+ versions.append((abspath, verstr, copyright, is_qt))
if not versions:
print(f'No binaries found in {builddir}. Please ensure the binaries are present in {builddir}, or set another build path using the BUILDDIR env variable.')
sys.exit(1)
-if any(verstr.endswith('-dirty') for (_, verstr, _) in versions):
+if any(verstr.endswith('-dirty') for (_, verstr, _, _) in versions):
print("WARNING: Binaries were built from a dirty tree.")
print('man pages generated from dirty binaries should NOT be committed.')
print('To properly generate man pages, please commit your changes (or discard them), rebuild, then run this script again.')
@@ -93,7 +98,16 @@ with tempfile.NamedTemporaryFile('w', suffix='.h2m') as footer:
footer.flush()
# Call the binaries through help2man to produce a manual page for each of them.
- for (abspath, verstr, _) in versions:
+ for (abspath, verstr, _, is_qt) in versions:
outname = os.path.join(mandir, os.path.basename(abspath) + '.1')
+ help_option = '--help-option=--help' + (' --lang=en' if is_qt else '')
print(f'Generating {outname}…')
- subprocess.run([help2man, '-N', '--version-string=' + verstr, '--include=' + footer.name, '-o', outname, abspath], check=True)
+ subprocess.run([
+ help2man,
+ '-N',
+ '--version-string=' + verstr,
+ '--include=' + footer.name,
+ '-o', outname,
+ help_option,
+ abspath,
+ ], check=True)
Why this scored 15/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.