fix: unclosed file handles in read_full_med_mentions() and read_ner_from_tsv()
- Langage dominant
- Python
- Étoiles
- 2k
- Forks
- 258
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
## Problem
Several functions in `scispacy/data_util.py` open file handles without closing them:
1. **Lines 188, 192, 196** in `read_full_med_mentions()`:
```python
train_ids = {x.strip() for x in open(os.path.join(resolved_directory_path, expected_names[4]))}
dev_ids = {x.strip() for x in open(os.path.join(resolved_directory_path, expected_names[2]))}
test_ids = {x.strip() for x in open(os.path.join(resolved_directory_path, expected_names[3]))}
```
2. **Line 302** in `read_ner_from_tsv()`:
```python
for line in open(cached_path(filename)):
```
These file handles are never explicitly closed. While CPython's reference counting typically handles cleanup, this is not guaranteed on other implementations (PyPy, Jython) and is a resource leak when processing many files.
## Affected Files
- `scispacy/data_util.py` lines 188, 192, 196, 302
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.