mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
Revert "gh-85567: Register a cleanup function to close files for FileType objects in argparse (#32257)" (#91771)
This reverts commit 328dbc051f
.
This commit is contained in:
parent
4e52c66f69
commit
c77953b23e
3 changed files with 3 additions and 11 deletions
|
@ -84,7 +84,7 @@ __all__ = [
|
|||
'ZERO_OR_MORE',
|
||||
]
|
||||
|
||||
import atexit as _atexit
|
||||
|
||||
import os as _os
|
||||
import re as _re
|
||||
import sys as _sys
|
||||
|
@ -1268,12 +1268,8 @@ class FileType(object):
|
|||
|
||||
# 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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue