From 5b0c60cd4be3899902e6a877da6436b5f6189680 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Fri, 6 Feb 2026 09:57:16 +0900 Subject: [PATCH] Make sure proc file is closed when reading --- src/find_libpython/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/find_libpython/__init__.py b/src/find_libpython/__init__.py index eded7af..d523143 100644 --- a/src/find_libpython/__init__.py +++ b/src/find_libpython/__init__.py @@ -147,7 +147,8 @@ def wrapper(*args: P.args, **kwds: P.kwargs) -> Iterable[str]: def _get_proc_library() -> Iterable[str]: pid = os.getpid() path = f"/proc/{pid}/maps" - lines = open(path).readlines() + with open(path) as f: + lines = f.readlines() for line in lines: path = line.split(" ", 5)[5].strip()