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:
54 files changed
+127
-128
No files matched your search
@@ -246,8 +246,8 @@ def files_are_equal(filename1, filename2):
|
||||
eq = contents1 == contents2
|
||||
|
||||
if not eq:
|
||||
with open(filename1, 'r', encoding='utf-8') as f1, \
|
||||
open(filename2, 'r', encoding='utf-8') as f2:
|
||||
with open(filename1, 'r') as f1, \
|
||||
open(filename2, 'r') as f2:
|
||||
f1lines = f1.readlines()
|
||||
f2lines = f2.readlines()
|
||||
|
||||
@@ -426,7 +426,7 @@ def verify_shasums_signature(
|
||||
def parse_sums_file(sums_file_path: str, filename_filter: list[str]) -> list[list[str]]:
|
||||
# extract hashes/filenames of binaries to verify from hash file;
|
||||
# each line has the following format: "<hash> <binary_filename>"
|
||||
with open(sums_file_path, 'r', encoding='utf8') as hash_file:
|
||||
with open(sums_file_path, 'r') as hash_file:
|
||||
return [line.split()[:2] for line in hash_file if len(filename_filter) == 0 or any(f in line for f in filename_filter)]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user