]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23269)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 13 Nov 2020 18:18:35 +0000 (10:18 -0800)
committerGitHub <noreply@github.com>
Fri, 13 Nov 2020 18:18:35 +0000 (13:18 -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 71d7a126ac320fc9f6babff06af9212e58c71676..998816b48610a1658751f8e142efd571163eae10 100644 (file)
@@ -355,7 +355,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`