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
@@ -134,7 +134,7 @@ class TestFrameworkEllSwift(unittest.TestCase):
|
||||
def test_elligator_encode_testvectors(self):
|
||||
"""Implement the BIP324 test vectors for ellswift encoding (read from xswiftec_inv_test_vectors.csv)."""
|
||||
vectors_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'xswiftec_inv_test_vectors.csv')
|
||||
with open(vectors_file, newline='', encoding='utf8') as csvfile:
|
||||
with open(vectors_file, newline='') as csvfile:
|
||||
reader = csv.DictReader(csvfile)
|
||||
for row in reader:
|
||||
u = FE.from_bytes(bytes.fromhex(row['u']))
|
||||
@@ -150,7 +150,7 @@ class TestFrameworkEllSwift(unittest.TestCase):
|
||||
def test_elligator_decode_testvectors(self):
|
||||
"""Implement the BIP324 test vectors for ellswift decoding (read from ellswift_decode_test_vectors.csv)."""
|
||||
vectors_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ellswift_decode_test_vectors.csv')
|
||||
with open(vectors_file, newline='', encoding='utf8') as csvfile:
|
||||
with open(vectors_file, newline='') as csvfile:
|
||||
reader = csv.DictReader(csvfile)
|
||||
for row in reader:
|
||||
encoding = bytes.fromhex(row['ellswift'])
|
||||
|
||||
Reference in new issue
Block a user