summaryrefslogtreecommitdiffstats
path: root/Tools/i18n
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-03-30 06:33:02 (GMT)
committerGitHub <noreply@github.com>2019-03-30 06:33:02 (GMT)
commit172bb39452ae8b3ccdf5d1f23ead46f44200cd49 (patch)
tree5e1effbca3664b839a81eb7a7d62fa4974cfbfb1 /Tools/i18n
parentafbb7a371fb44edc731344eab5b474ad8f7b57d7 (diff)
downloadcpython-172bb39452ae8b3ccdf5d1f23ead46f44200cd49.zip
cpython-172bb39452ae8b3ccdf5d1f23ead46f44200cd49.tar.gz
cpython-172bb39452ae8b3ccdf5d1f23ead46f44200cd49.tar.bz2
bpo-22831: Use "with" to avoid possible fd leaks in tools (part 2). (GH-10927)
Diffstat (limited to 'Tools/i18n')
-rwxr-xr-xTools/i18n/pygettext.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py
index b46dd33..b1d281d 100755
--- a/Tools/i18n/pygettext.py
+++ b/Tools/i18n/pygettext.py
@@ -561,9 +561,8 @@ def main():
# initialize list of strings to exclude
if options.excludefilename:
try:
- fp = open(options.excludefilename)
- options.toexclude = fp.readlines()
- fp.close()
+ with open(options.excludefilename) as fp:
+ options.toexclude = fp.readlines()
except IOError:
print(_(
"Can't read --exclude-file: %s") % options.excludefilename, file=sys.stderr)