#18853: Fix resource warning in shlex's __main__ section.
Report and original fix by Vajrasky Kok.
This commit is contained in:
parent
7570cbdc6b
commit
838f2c437d
20
Lib/shlex.py
20
Lib/shlex.py
|
@ -290,15 +290,17 @@ def quote(s):
|
||||||
return "'" + s.replace("'", "'\"'\"'") + "'"
|
return "'" + s.replace("'", "'\"'\"'") + "'"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def _print_tokens(lexer):
|
||||||
if len(sys.argv) == 1:
|
|
||||||
lexer = shlex()
|
|
||||||
else:
|
|
||||||
file = sys.argv[1]
|
|
||||||
lexer = shlex(open(file), file)
|
|
||||||
while 1:
|
while 1:
|
||||||
tt = lexer.get_token()
|
tt = lexer.get_token()
|
||||||
if tt:
|
if not tt:
|
||||||
print("Token: " + repr(tt))
|
|
||||||
else:
|
|
||||||
break
|
break
|
||||||
|
print("Token: " + repr(tt))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
_print_tokens(shlex())
|
||||||
|
else:
|
||||||
|
fn = sys.argv[1]
|
||||||
|
with open(fn) as f:
|
||||||
|
_print_tokens(shlex(f, fn))
|
||||||
|
|
|
@ -33,6 +33,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #18853: Fixed ResourceWarning in shlex.__nain__.
|
||||||
|
|
||||||
- Issue #9351: Defaults set with set_defaults on an argparse subparser
|
- Issue #9351: Defaults set with set_defaults on an argparse subparser
|
||||||
are no longer ignored when also set on the parent parser.
|
are no longer ignored when also set on the parent parser.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue