mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-09 22:28:51 +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:
@@ -32,7 +32,7 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||
def setup_network(self):
|
||||
self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
|
||||
# Open and close to create zero-length file
|
||||
with open(self.alert_filename, 'w', encoding='utf8'):
|
||||
with open(self.alert_filename, 'w'):
|
||||
pass
|
||||
self.extra_args = [[f"-alertnotify=echo %s >> \"{self.alert_filename}\""]]
|
||||
self.setup_nodes()
|
||||
@@ -55,7 +55,7 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||
|
||||
def versionbits_in_alert_file(self):
|
||||
"""Test that the versionbits warning has been written to the alert file."""
|
||||
with open(self.alert_filename, 'r', encoding='utf8') as f:
|
||||
with open(self.alert_filename, 'r') as f:
|
||||
alert_text = f.read()
|
||||
return VB_PATTERN.search(alert_text) is not None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user