Skip to content

Commit f1b8d40

Browse files
authored
Revert "gh-85567: Register a cleanup function to close files for FileType objects in argparse (#32257)"
This reverts commit 328dbc0.
1 parent 25e3574 commit f1b8d40

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

Lib/argparse.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
'ZERO_OR_MORE',
8585
]
8686

87-
import atexit as _atexit
87+
8888
import os as _os
8989
import re as _re
9090
import sys as _sys
@@ -1268,12 +1268,8 @@ def __call__(self, string):
12681268

12691269
# all other arguments are used as file names
12701270
try:
1271-
fh = open(string, self._mode, self._bufsize, self._encoding, self._errors)
1272-
1273-
# Register cleanup function to close file
1274-
_atexit.register(fh.close)
1275-
1276-
return fh
1271+
return open(string, self._mode, self._bufsize, self._encoding,
1272+
self._errors)
12771273
except OSError as e:
12781274
args = {'filename': string, 'error': e}
12791275
message = _("can't open '%(filename)s': %(error)s")

Misc/ACKS

-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ Nicolas Chauvat
313313
Jerry Chen
314314
Michael Chermside
315315
Ingrid Cheung
316-
Adam Chhina
317316
Terry Chia
318317
Albert Chin-A-Young
319318
Adal Chiriliuc

Misc/NEWS.d/next/Library/2022-04-02-14-40-53.bpo-41395.Y1ZVvT.rst

-3
This file was deleted.

0 commit comments

Comments
 (0)