diff options
author | Raymond Hettinger <python@rcn.com> | 2014-05-26 07:43:27 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2014-05-26 07:43:27 (GMT) |
commit | dea46ec9654a6412e74a6f8dfbdf97ff97516670 (patch) | |
tree | 6e157f543c738ecdf463a53afde142cb007a660e /Lib/argparse.py | |
parent | dd5e53a086fcabc84ee1ac96b98057437863973a (diff) | |
download | cpython-dea46ec9654a6412e74a6f8dfbdf97ff97516670.zip cpython-dea46ec9654a6412e74a6f8dfbdf97ff97516670.tar.gz cpython-dea46ec9654a6412e74a6f8dfbdf97ff97516670.tar.bz2 |
Issue #21481: Teach argparse equality tests to return NotImplemented when comparing to unknown types.
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r-- | Lib/argparse.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index 5ad7e13..83878b1 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1198,9 +1198,13 @@ class Namespace(_AttributeHolder): setattr(self, name, kwargs[name]) def __eq__(self, other): + if not isinstance(other, Namespace): + return NotImplemented return vars(self) == vars(other) def __ne__(self, other): + if not isinstance(other, Namespace): + return NotImplemented return not (self == other) def __contains__(self, key): |