Skip to content

Commit db7d457

Browse files
lfoppianoCopilot
andauthored
Avoid leaking opened files
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 21c6cb5 commit db7d457

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

grobid_client/format/TEI2LossyJSON.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def convert_tei_file(self, tei_file: Union[Path, BinaryIO], stream: bool = False
3939
If stream=False returns the full document dict (same shape as original function).
4040
"""
4141
# Load with BeautifulSoup but avoid building huge structures when streaming
42-
content = open(tei_file, 'r').read()
42+
with open(tei_file, 'r') as f:
43+
content = f.read()
4344
soup = BeautifulSoup(content, 'xml')
4445

4546
if soup.TEI is None:

0 commit comments

Comments
 (0)