Closed
Description
Bug report
Bug description:
consider the following program, it should raise an ExceptionGroup(..., [ValueError(), ValueError(), ...] but actually it raises OSError: [Errno 24] Too many open files: '/tmp/tmpk8gaprry'
import gzip
import tempfile
import pathlib
import os
def main():
with tempfile.TemporaryDirectory() as tmp_dir:
tmp_path = pathlib.Path(tmp_dir)
zip_path = tmp_path / "some_file.zip"
exceptions = []
for i in range(2000):
try:
gzip.GzipFile(filename=os.fsdecode(zip_path), mode="w", compresslevel=99)
except ValueError as e:
exceptions.append(e)
if exceptions:
raise ExceptionGroup("multiple errors creating GzipFiles", exceptions)
main()
CPython versions tested on:
CPython main branch, 3.14, 3.13, 3.12, 3.11
Operating systems tested on:
Linux
Linked PRs
- gh-131492: gh-131461: handle exceptions in GzipFile constructor while owning resources #131462
- [3.13] gh-131492, gh-131461: handle exceptions in GzipFile constructor while owning resources (GH-131462) #131518
- [3.12] gh-131492, gh-131461: handle exceptions in GzipFile constructor while owning resources (GH-131462) #131519