Avoid closing files multiple times in getInterpreter(#17665)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
authored and GitHub committed 2025-06-25 14:27:33 +08:00
1 parent 0e6ec982df
commit 37f6e09589
2 files changed
+19 -18

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
#### Avoid closing files multiple times (#17665 by @43081j)
When reading a file to infer the interpreter from a shebang, we use the
`n-readlines` library to read the first line in order to get the shebang.
This library closes files when it reaches EOF, and we later try close the same
files again. We now close files only if `n-readlines` did not already close
them.