While working on the PEP 475, I modified _Py_fopen_obj() to raise the OSError (instead of raising the exception from the call site). The zipimport uses _Py_fopen_obj() but it didn't raise OSError, only ZipImportError. I modified the zipimport module to raise a chained exception: OSError chained to ZipImportError: see issue #23696.
Other functions using _PyErr_ChainExceptions():
- open() (io.open): if open() failed and f.close() raised an exception, chain the two exceptions
- io.FileIO.close
- io.TextIOWrapper.close
- io.BufferedReader.close, io.BufferedWriter.close
- _Py_CheckFunctionResult(), new function introduced in the issue #23571 |