[issue46101] argparse: using parents & subcommands, options can be ignored
Lucas Cimon added the comment: The GitHub PR is ready for reviewing. -- ___ Python tracker <https://bugs.python.org/issue46101> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38584] argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help
Lucas Cimon added the comment: This was resolved by https://github.com/python/cpython/pull/28050 -- message_count: 4.0 -> 5.0 pull_requests: +28366 status: open -> closed pull_request: https://github.com/python/cpython/pull/28050 ___ Python tracker <https://bugs.python.org/issue38584> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46101] argparse: using parents & subcommands, options can be ignored
Change by Lucas Cimon : -- keywords: +patch pull_requests: +28364 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30146 ___ Python tracker <https://bugs.python.org/issue46101> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46101] argparse: using parents & subcommands, options can be ignored
New submission from Lucas Cimon : Hi! Here is some minimal code reproducing the issue: import argparse common_opts_parser = argparse.ArgumentParser(add_help=False) common_opts_parser.add_argument("--endpoint", choices=("prod", "dev"), default="dev") parser = argparse.ArgumentParser(parents=[common_opts_parser]) subparsers = parser.add_subparsers(required=True) subcmd_cmd = subparsers.add_parser("subcmd", parents=[common_opts_parser]) subcmd_cmd.add_argument("--debug", action="store_true") print(parser.parse_args()) Everything works fine / as expected when specifying the common optional arg last: $ ./bug_repro.py subcmd --endpoint=dev Namespace(endpoint='dev', debug=False) However when specifying the --endpoint between the program and the subcommand, the value provided is ignored: $ ./bug_repro.py --endpoint=dev subcmd Namespace(endpoint=None, debug=False) I have a PR ready to fix that. -- components: Library (Lib) messages: 408711 nosy: Lucas Cimon priority: normal severity: normal status: open title: argparse: using parents & subcommands, options can be ignored type: behavior versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue46101> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33109] argparse: make new 'required' argument to add_subparsers default to False instead of True
Lucas Cimon added the comment: Sorry, the fix was by Mathias Ettinger: elif isinstance(argument, _SubParsersAction): return '{%s}' % ','.join(map(str, argument.choices)) I submitted a PR with this patch and a corresponding unit test: https://github.com/python/cpython/pull/26278 -- ___ Python tracker <https://bugs.python.org/issue33109> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29298] argparse fails with required subparsers, un-named dest, and empty argv
Change by Lucas Cimon : -- nosy: +Lucas Cimon nosy_count: 7.0 -> 8.0 pull_requests: +24884 pull_request: https://github.com/python/cpython/pull/26278 ___ Python tracker <https://bugs.python.org/issue29298> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33109] argparse: make new 'required' argument to add_subparsers default to False instead of True
Lucas Cimon added the comment: Reporting a duplicate / superseder with the following bug: parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(required=True) subparsers.add_parser('foo') parser.parse_args() Raising: TypeError: sequence item 0: expected str instance, NoneType found It has already been reported in https://bugs.python.org/issue29298 with an interesting solution by Greg Minshall. -- nosy: +Lucas Cimon ___ Python tracker <https://bugs.python.org/issue33109> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38584] argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help
Lucas Cimon added the comment: Thanks for the feedbacks paul.j3 ! I totally agree it would be best to test all formatter classes. I modified the new test to do so. I think I should probably place this test somewhere else in test_argparse.py, but I'm having trouble figuring out where exactly... I just updated the PR and moved the new test to the TestOptionalsHelpVersionActions class. About the best fix, I think a fix to _split_lines() would be more complex. It needs to return a list, so we would make it return [''] in that case ? That would be a bit strange. What do you think ? :) -- ___ Python tracker <https://bugs.python.org/issue38584> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38586] logging: handlers names are not set when using fileConfig
Change by Lucas Cimon : -- keywords: +patch pull_requests: +16450 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16918 ___ Python tracker <https://bugs.python.org/issue38586> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38586] logging: handlers names are not set when using fileConfig
New submission from Lucas Cimon : The logging.Handler .name property is not set when the logging configuration is loaded with logging.fileConfig -- components: Library (Lib) messages: 355338 nosy: Lucas Cimon priority: normal severity: normal status: open title: logging: handlers names are not set when using fileConfig versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue38586> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38584] argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help
Change by Lucas Cimon : -- keywords: +patch pull_requests: +16448 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16917 ___ Python tracker <https://bugs.python.org/issue38584> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38584] argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help
New submission from Lucas Cimon : The test I am going to add to test_argparse.py: def test_whitespace_help(self): parser = self._get_parser() parser.add_argument( '--foo2', action='store_true', help=' ') parser.add_argument( 'bar2', type=float, help=' ') parser.format_help() # raises an IndexError -- components: Library (Lib) messages: 355336 nosy: Lucas Cimon priority: normal severity: normal status: open title: argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue38584> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35720] Memory leak in Modules/main.c:pymain_parse_cmdline_impl when using the CLI flag
New submission from Lucas Cimon : Hi. I think I have found a minor memory leak in Modules/main.c:pymain_parse_cmdline_impl. When the loop in the pymain_read_conf function in this same file calls pymain_init_cmdline_argv a 2nd time, the pymain->command buffer of wchar_t is overriden and the previously allocated memory is never freed. I haven't written any code test to reproduce this, but it can be tested easily with gdb: ``` gdb -- bin/python3 -c pass start b Modules/main.c:587 b pymain_clear_pymain c c ``` You'll see that PyMem_RawMalloc is called twice without pymain->command ever being freed in pymain_clear_pymain. I have a patch coming as PR on GitHub I'd be glad to have your feedback on this issue and my proposal for a fix. Regards. -- messages: 333499 nosy: Lucas Cimon priority: normal severity: normal status: open title: Memory leak in Modules/main.c:pymain_parse_cmdline_impl when using the CLI flag ___ Python tracker <https://bugs.python.org/issue35720> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com