Skip to content

Commit abcb976

Browse files
whitslackrustyrussell
authored andcommitted
pyln-testing: close 'config.vars' after reading
This code has a resource leak: lines = open(fname, 'r').readlines() This is the correct way: with open(fname, 'r') as f: lines = f.readlines() Changelog-None
1 parent 7e9729b commit abcb976

File tree

1 file changed

+2
-1
lines changed
  • contrib/pyln-testing/pyln/testing

1 file changed

+2
-1
lines changed

contrib/pyln-testing/pyln/testing/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def env(name, default=None):
6060
"""
6161
fname = 'config.vars'
6262
if os.path.exists(fname):
63-
lines = open(fname, 'r').readlines()
63+
with open(fname, 'r') as f:
64+
lines = f.readlines()
6465
config = dict([(line.rstrip().split('=', 1)) for line in lines])
6566
else:
6667
config = {}

0 commit comments

Comments
 (0)