mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-03 04:01:43 +02:00
test, contrib, refactor: use with
when opening a file
This commit is contained in:
@ -247,7 +247,8 @@ class ConfArgsTest(BitcoinTestFramework):
|
||||
conf_file = os.path.join(default_data_dir, "bitcoin.conf")
|
||||
|
||||
# datadir needs to be set before [chain] section
|
||||
conf_file_contents = open(conf_file, encoding='utf8').read()
|
||||
with open(conf_file, encoding='utf8') as f:
|
||||
conf_file_contents = f.read()
|
||||
with open(conf_file, 'w', encoding='utf8') as f:
|
||||
f.write(f"datadir={new_data_dir}\n")
|
||||
f.write(conf_file_contents)
|
||||
|
Reference in New Issue
Block a user