Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added import as top level import, and renamed file as fh.
  • Loading branch information
achhina committed Apr 14, 2022
commit a47430fff73363b0f21cc0d437eac738562c7643
10 changes: 4 additions & 6 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,14 +1268,12 @@ def __call__(self, string):

# all other arguments are used as file names
try:
file = open(string, self._mode, self._bufsize, self._encoding,
self._errors)
fh = open(string, self._mode, self._bufsize, self._encoding, self._errors)

# Register cleanup function to close file
import atexit
atexit.register(file.close)
_atexit.register(fh.close)

return file
return fh
except OSError as e:
args = {'filename': string, 'error': e}
message = _("can't open '%(filename)s': %(error)s")
Expand Down