Fix a bunch of potential file descriptor leaks

Some are unconditional, some are only if there were exceptions raised between the open and close. All of these were noticed when switching from pycompat.open() a few weeks ago.

Merge request reports

Loading