[issue39333] argparse should offer an alternative to SystemExit in case a parse fails
New submission from Jack Orenstein : If parse_args fails, SystemExit is raised, carrying an exit code of 2, and the help message is printed. For an embedded usage of argparse, this behavior is undesirable. I am writing an interactive console application, using argparse to parse input. When a parse fails, I would like to print an error message and continue, not terminate the program. Currently, I need to catch SystemExit to be able to do this, which has obvious problems, (e.g., what if something other that argparse is causing the exit?) I'd like to see some way to specify alternative behavior, e.g. raise an exception of a given type. -- components: Library (Lib) messages: 359991 nosy: geophile priority: normal severity: normal status: open title: argparse should offer an alternative to SystemExit in case a parse fails type: enhancement ___ Python tracker <https://bugs.python.org/issue39333> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39333] argparse should offer an alternative to SystemExit in case a parse fails
Jack Orenstein added the comment: Yes! I didn't know about that method, thank you. -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue39333> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40363] shlex.quote applied to a glob pattern disables glob matching
New submission from Jack Orenstein : I am using shlex.quote to pass filenames to a shell command, e.g. ls. The problem is that glob patterns, when quoted, no longer operate as glob patterns. So, for example, executing this: ls 'var/log/syslog*' results in this output: ls: cannot access '/var/log/syslog*': No such file or directory The documentation for shlex.quote says: "Return a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line, for cases where you cannot use a list." I believe that quoting needs to preserve glob semantics to fulfill the documented goal. For example, it seems to me that quoting as follows would be better: ls '/var/log/syslog'* -- components: Library (Lib) messages: 367010 nosy: geophile priority: normal severity: normal status: open title: shlex.quote applied to a glob pattern disables glob matching versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue40363> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com