diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2023-06-05 07:14:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 07:14:00 (GMT) |
commit | 9efaff5fd31a55e3beaa1fa430058de36a145566 (patch) | |
tree | 0f24d40480c495b7a78af99ef1349bdbcc44bb6a /Lib/argparse.py | |
parent | 418befd75d4d0d1cba83d8b81e1a7bcc9a65be8e (diff) | |
download | cpython-9efaff5fd31a55e3beaa1fa430058de36a145566.zip cpython-9efaff5fd31a55e3beaa1fa430058de36a145566.tar.gz cpython-9efaff5fd31a55e3beaa1fa430058de36a145566.tar.bz2 |
gh-103558: Add coverage tests for argparse (#103570)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r-- | Lib/argparse.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index 543d994..dfc9869 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1528,6 +1528,8 @@ class _ActionsContainer(object): title_group_map = {} for group in self._action_groups: if group.title in title_group_map: + # This branch could happen if a derived class added + # groups with duplicated titles in __init__ msg = _('cannot merge actions - two groups are named %r') raise ValueError(msg % (group.title)) title_group_map[group.title] = group @@ -1811,13 +1813,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): # add parent arguments and defaults for parent in parents: + if not isinstance(parent, ArgumentParser): + raise TypeError('parents must be a list of ArgumentParser') self._add_container_actions(parent) - try: - defaults = parent._defaults - except AttributeError: - pass - else: - self._defaults.update(defaults) + defaults = parent._defaults + self._defaults.update(defaults) # ======================= # Pretty __repr__ methods |