lint: Drop check to enforce encoding to be specified in Python scripts
What changed, and why it matters
This commit removes a lint (code-quality) script that checked whether Python code in the repository explicitly specified UTF-8 encoding when opening text files or reading subprocess output. It is a tooling/development cleanup, not a change to Bitcoin Core's runtime code, consensus logic, wallet handling, or network behavior. There is no direct security vulnerability in the diff itself.
No security action required. Developers may want to confirm that CI no longer relies on this lint script and that an alternative (such as PYTHONWARNDEFAULTENCODING=1 or a replacement linter) is adopted if the project still wants to guard against locale-dependent encoding issues on Windows or BSDs.
Security signals we found
No changes to runtime, consensus, wallet, or networking code
Only a lint/CI script is removed
No cryptographic, input-validation, or privilege-boundary changes
No CVE, advisory, or vendor security disclosure referenced in commit
Evidence from the diff
The deleted file test/lint/lint-python-utf8-encoding.py enforced a project style rule requiring encoding=’utf8’ (or ascii/utf-8) on Python open(…) and subprocess.check_output(…, text=True) calls. The commit message argues the check is incomplete/brittle, that modern systems default to UTF-8, and that explicit encoding arguments bloat the code. The diff only deletes this lint script; no other source files are modified. The change does not alter how Bitcoin Core nodes process transactions, validate blocks, manage keys, or communicate over the network.
Changed components
test/lint/lint-python-utf8-encoding.pyInspect captured patch +0 / −73
diff --git a/test/lint/lint-python-utf8-encoding.py b/test/lint/lint-python-utf8-encoding.py
deleted file mode 100755
index 8c926647..00000000
--- a/test/lint/lint-python-utf8-encoding.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright (c) 2018-2022 The Bitcoin Core developers
-# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#
-# Make sure we explicitly open all text files using UTF-8 (or ASCII) encoding to
-# avoid potential issues on the BSDs where the locale is not always set.
-
-import sys
-import re
-
-from subprocess import check_output, CalledProcessError
-
-EXCLUDED_DIRS = ["src/crc32c/", "src/secp256k1/"]
-
-
-def get_exclude_args():
- return [":(exclude)" + dir for dir in EXCLUDED_DIRS]
-
-
-def check_fileopens():
- fileopens = list()
-
- try:
- fileopens = check_output(["git", "grep", r" open(", "--", "*.py"] + get_exclude_args(), text=True, encoding="utf8").splitlines()
- except CalledProcessError as e:
- if e.returncode > 1:
- raise e
-
- filtered_fileopens = [fileopen for fileopen in fileopens if not re.search(r"encoding=.(ascii|utf8|utf-8).|open\([^,]*, (\*\*kwargs|['\"][^'\"]*b[^'\"]*['\"])", fileopen)]
-
- return filtered_fileopens
-
-
-def check_checked_outputs():
- checked_outputs = list()
-
- try:
- checked_outputs = check_output(["git", "grep", "check_output(", "--", "*.py"] + get_exclude_args(), text=True, encoding="utf8").splitlines()
- except CalledProcessError as e:
- if e.returncode > 1:
- raise e
-
- filtered_checked_outputs = [checked_output for checked_output in checked_outputs if re.search(r"text=True", checked_output) and not re.search(r"encoding=.(ascii|utf8|utf-8).", checked_output)]
-
- return filtered_checked_outputs
-
-
-def main():
- exit_code = 0
-
- nonexplicit_utf8_fileopens = check_fileopens()
- if nonexplicit_utf8_fileopens:
- print("Python's open(...) seems to be used to open text files without explicitly specifying encoding='utf8':\n")
- for fileopen in nonexplicit_utf8_fileopens:
- print(fileopen)
- exit_code = 1
-
- nonexplicit_utf8_checked_outputs = check_checked_outputs()
- if nonexplicit_utf8_checked_outputs:
- if nonexplicit_utf8_fileopens:
- print("\n")
- print("Python's check_output(...) seems to be used to get program outputs without explicitly specifying encoding='utf8':\n")
- for checked_output in nonexplicit_utf8_checked_outputs:
- print(checked_output)
- exit_code = 1
-
- sys.exit(exit_code)
-
-
-if __name__ == "__main__":
- main()
Why this scored 14/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.