Skip to content

Commit 3fa5fd5

Browse files
anuraagaktbarrett
authored andcommitted
Make sure proc file is closed when reading
1 parent a5a8f72 commit 3fa5fd5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/find_libpython/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ def wrapper(*args: P.args, **kwds: P.kwargs) -> Iterable[str]:
147147
def _get_proc_library() -> Iterable[str]:
148148
pid = os.getpid()
149149
path = f"/proc/{pid}/maps"
150-
lines = open(path).readlines()
150+
with open(path) as f:
151+
lines = f.readlines()
151152

152153
for line in lines:
153154
path = line.split(" ", 5)[5].strip()

0 commit comments

Comments
 (0)