mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-12 15:49:31 +02:00
contrib: Remove confusing and redundant encoding from IO
The encoding arg is confusing, because it is not applied consistently for all IO. Also, it is useless, as the majority of files are ASCII encoded, which are fine to encode and decode with any mode. Moreover, UTF-8 is already required for most scripts to work properly, so setting the encoding twice is redundant. So remove the encoding from most IO. It would be fine to remove from all IO, however I kept it for two files: * contrib/asmap/asmap-tool.py: This specifically looks for utf-8 encoding errors, so it makes sense to sepecify the utf-8 encoding explicitly. * test/functional/test_framework/test_node.py: Reading the debug log in text mode specifically counts the utf-8 characters (not bytes), so it makes sense to specify the utf-8 encoding explicitly.
This commit is contained in:
@@ -22,7 +22,7 @@ def process_mapping(fname):
|
||||
cmds = []
|
||||
string_params = []
|
||||
in_rpcs = False
|
||||
with open(fname, "r", encoding="utf8") as f:
|
||||
with open(fname, "r") as f:
|
||||
for line in f:
|
||||
line = line.rstrip()
|
||||
if not in_rpcs:
|
||||
@@ -153,7 +153,7 @@ class HelpRpcTest(BitcoinTestFramework):
|
||||
os.mkdir(dump_dir)
|
||||
calls = [line.split(' ', 1)[0] for line in self.nodes[0].help().splitlines() if line and not line.startswith('==')]
|
||||
for call in calls:
|
||||
with open(os.path.join(dump_dir, call), 'w', encoding='utf-8') as f:
|
||||
with open(os.path.join(dump_dir, call), 'w') as f:
|
||||
# Make sure the node can generate the help at runtime without crashing
|
||||
f.write(self.nodes[0].help(call))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user