Skip to content

Commit

Permalink
Revert "gh-85567: Register a cleanup function to close files for File…
Browse files Browse the repository at this point in the history
…Type objects in argparse (#32257)"

This reverts commit 328dbc0.
  • Loading branch information
vstinner authored Apr 21, 2022
1 parent 25e3574 commit f1b8d40
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
10 changes: 3 additions & 7 deletions Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
'ZERO_OR_MORE',
]

import atexit as _atexit

import os as _os
import re as _re
import sys as _sys
Expand Down Expand Up @@ -1268,12 +1268,8 @@ def __call__(self, string):

# 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")
Expand Down
1 change: 0 additions & 1 deletion Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ Nicolas Chauvat
Jerry Chen
Michael Chermside
Ingrid Cheung
Adam Chhina
Terry Chia
Albert Chin-A-Young
Adal Chiriliuc
Expand Down

This file was deleted.

0 comments on commit f1b8d40

Please sign in to comment.