Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

argparse.ArgumentParser.parses_args does not honor exit_on_error=False when given unrecognized arguments #121018

Closed
Labels
type-bugAn unexpected behavior, bug, or error
@blhsing

Description

@blhsing

Bug report

Bug description:

As reported inDiscourse, even though the documentation on theexit_on_error argument forargparse.ArgumentParser says:

exit_on_error - Determines whether or notArgumentParser exits with error info when an error occurs. (default:True)

Theparse_args method would still exit with error info when there are unrecognized arguments:

importargparseparser=argparse.ArgumentParser(exit_on_error=False)try:parser.parse_args('invalid arguments'.split())exceptargparse.ArgumentError:print('ArgumentError caught.')

which outputs:

usage: test.py [-h]test.py: error: unrecognized arguments: invalid arguments

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

Linux, Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Doc issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp