Skip to content

Commit af228ca

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

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
@@ -302,7 +302,8 @@ def _convert_file_worker(path: str):
302302
import dateparser
303303
# Reuse existing top-level helpers from this module by importing here
304304
from grobid_client.format.TEI2LossyJSON import box_to_dict, get_random_id, get_formatted_passage, get_refs_with_offsets, xml_table_to_json
305-
content = open(path, 'r').read()
305+
with open(path, 'r') as f:
306+
content = f.read()
306307
soup = BeautifulSoup(content, 'xml')
307308
converter = TEI2LossyJSONConverter()
308309
return converter.convert_tei_file(path, stream=False)

0 commit comments

Comments
 (0)