]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264)
authorJürgen Gmach <juergen.gmach@googlemail.com>
Fri, 13 Nov 2020 18:15:37 +0000 (19:15 +0100)
committerGitHub <noreply@github.com>
Fri, 13 Nov 2020 18:15:37 +0000 (13:15 -0500)
Doc/library/types.rst

index ad40a9fbf327398c10ace11b3fa2daf1a104d6d6..6f0dc259303fadf3008ba49246c02c27217eacdb 100644 (file)
@@ -409,7 +409,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`