gh-80259: Fix conflict between type and default=SUPPRESS in argparse (GH-124519)

type() no longer called for SUPPRESS.

This only affects positional arguments with nargs='?'.
This commit is contained in:
Serhiy Storchaka 2024-09-29 10:47:06 +03:00 committed by GitHub
parent 49e105f948
commit 9bcadf589a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 8 deletions

View file

@ -2483,7 +2483,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
value = action.const
else:
value = action.default
if isinstance(value, str):
if isinstance(value, str) and value is not SUPPRESS:
value = self._get_value(action, value)
self._check_value(action, value)