]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23270)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 13 Nov 2020 18:19:05 +0000 (10:19 -0800)
committerGitHub <noreply@github.com>
Fri, 13 Nov 2020 18:19:05 +0000 (13:19 -0500)
(cherry picked from commit bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3)

Co-authored-by: Jürgen Gmach <juergen.gmach@googlemail.com>
Co-authored-by: Jürgen Gmach <juergen.gmach@googlemail.com>
Doc/library/types.rst

index 5d68c6852678c2a770378912fc9d409dd57956f4..0fe3822fa542e333930dffd608b9a8a378bbbe8a 100644 (file)
@@ -384,7 +384,9 @@ Additional Utility Classes and Functions
                return "{}({})".format(type(self).__name__, ", ".join(items))
 
            def __eq__(self, other):
-               return self.__dict__ == other.__dict__
+               if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):
+                  return self.__dict__ == other.__dict__
+               return NotImplemented
 
    ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.
    However, for a structured record type use :func:`~collections.namedtuple`