'ZERO_OR_MORE',
]
-import atexit as _atexit
+
import os as _os
import re as _re
import sys as _sys
# all other arguments are used as file names
try:
- fh = open(string, self._mode, self._bufsize, self._encoding, self._errors)
-
- # Register cleanup function to close file
- _atexit.register(fh.close)
-
- return fh
+ return open(string, self._mode, self._bufsize, self._encoding,
+ self._errors)
except OSError as e:
args = {'filename': string, 'error': e}
message = _("can't open '%(filename)s': %(error)s")
+++ /dev/null
-FileType objects from argparse may not be closed and lead to
-ResourceWarning. Register a file.close function with atexit for FileType
-objects to ensure they are closed. Patch Contributed by Adam Chhina.