aboutsummaryrefslogtreecommitdiff
path: root/contrib/devtools
diff options
context:
space:
mode:
authorlaanwj <126646+laanwj@users.noreply.github.com>2022-05-04 19:52:09 +0200
committerlaanwj <126646+laanwj@users.noreply.github.com>2022-05-04 19:52:16 +0200
commit0047d9b89b9fa6be660c363961cf0af72fa62ecf (patch)
treeed887b5f7e593cbf405f9feff3d3755b1e96bda2 /contrib/devtools
parentbde5836f99966b382463a585db87faae27514a70 (diff)
parent027aab663aaca32818051d456c3900326377281c (diff)
downloadbitcoin-0047d9b89b9fa6be660c363961cf0af72fa62ecf.tar.xz
Merge bitcoin/bitcoin#24993: test, contrib, refactor: use `with` when opening a file
027aab663aaca32818051d456c3900326377281c test, contrib, refactor: use `with` when opening a file (brunoerg) Pull request description: When manipulating a file in Python without using `with()`, you have to close the file manually, so this PR does it in `get_block_hashes` (`contrib/linearize/linearize-data.py`). Edit: this PR does it for all occurances that previously weren't using `with`. ACKs for top commit: laanwj: Code review ACK 027aab663aaca32818051d456c3900326377281c Tree-SHA512: 879400968e0013e8678ec16f1fe5d0963a73c1e0d442ca34802d885214f0783d2e9a9b500fc6be7c3b93560a367b6a3d685eee24d2f9ce53fddf064ea6feecf8
Diffstat (limited to 'contrib/devtools')
-rwxr-xr-xcontrib/devtools/copyright_header.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py
index 38f3df77c9..e20eb4b0d2 100755
--- a/contrib/devtools/copyright_header.py
+++ b/contrib/devtools/copyright_header.py
@@ -320,15 +320,13 @@ def get_most_recent_git_change_year(filename):
################################################################################
def read_file_lines(filename):
- f = open(filename, 'r', encoding="utf8")
- file_lines = f.readlines()
- f.close()
+ with open(filename, 'r', encoding="utf8") as f:
+ file_lines = f.readlines()
return file_lines
def write_file_lines(filename, file_lines):
- f = open(filename, 'w', encoding="utf8")
- f.write(''.join(file_lines))
- f.close()
+ with open(filename, 'w', encoding="utf8") as f:
+ f.write(''.join(file_lines))
################################################################################
# update header years execution