mirror of
https://github.com/python/cpython.git
synced 2025-10-01 12:52:18 +00:00
Merge: #18853: Fix resource warning in shlex's __main__ section.
This commit is contained in:
commit
d20ec1b921
2 changed files with 13 additions and 9 deletions
20
Lib/shlex.py
20
Lib/shlex.py
|
@ -290,15 +290,17 @@ def quote(s):
|
|||
return "'" + s.replace("'", "'\"'\"'") + "'"
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 1:
|
||||
lexer = shlex()
|
||||
else:
|
||||
file = sys.argv[1]
|
||||
lexer = shlex(open(file), file)
|
||||
def _print_tokens(lexer):
|
||||
while 1:
|
||||
tt = lexer.get_token()
|
||||
if tt:
|
||||
print("Token: " + repr(tt))
|
||||
else:
|
||||
if not tt:
|
||||
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))
|
||||
|
|
|
@ -181,6 +181,8 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #18853: Fixed ResourceWarning in shlex.__nain__.
|
||||
|
||||
- Issue #9351: Defaults set with set_defaults on an argparse subparser
|
||||
are no longer ignored when also set on the parent parser.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue