cpython: 4c2b77d0680b (original) (raw)
Mercurial > cpython
changeset 93123:4c2b77d0680b 3.4
#18853: Fix resource warning in shlex's __main__ section. Report and original fix by Vajrasky Kok. [#18853]
R David Murray rdmurray@bitdance.com | |
---|---|
date | Fri, 17 Oct 2014 20:28:47 -0400 |
parents | e9cb45ccf42b |
children | 8ed630f28753 7c183c782401 |
files | Lib/shlex.py Misc/NEWS |
diffstat | 2 files changed, 13 insertions(+), 9 deletions(-)[+] [-] Lib/shlex.py 20 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -290,15 +290,17 @@ def quote(s): return "'" + s.replace("'", "'"'"'") + "'" +def _print_tokens(lexer):
- while 1:
tt = lexer.get_token()[](#l1.9)
if not tt:[](#l1.10)
break[](#l1.11)
print("Token: " + repr(tt))[](#l1.12)
+ if name == 'main': if len(sys.argv) == 1:
lexer = shlex()[](#l1.16)
file = sys.argv[1][](#l1.19)
lexer = shlex(open(file), file)[](#l1.20)
- while 1:
tt = lexer.get_token()[](#l1.22)
if tt:[](#l1.23)
print("Token: " + repr(tt))[](#l1.24)
else:[](#l1.25)
break[](#l1.26)
fn = sys.argv[1][](#l1.27)
with open(fn) as f:[](#l1.28)
_print_tokens(shlex(f, fn))[](#l1.29)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -33,6 +33,8 @@ Core and Builtins Library ------- +- Issue #18853: Fixed ResourceWarning in shlex.nain. +