[pypy-commit] pypy py3.5: tweak SimpleNamespace.__eq__ and __ne__

arigo pypy.commits at gmail.com
Wed Nov 30 10:46:39 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88778:3cce9c2e561f
Date: 2016-11-30 16:45 +0100
http://bitbucket.org/pypy/pypy/changeset/3cce9c2e561f/

Log:	tweak SimpleNamespace.__eq__ and __ne__

diff --git a/pypy/module/sys/app.py b/pypy/module/sys/app.py
--- a/pypy/module/sys/app.py
+++ b/pypy/module/sys/app.py
@@ -131,8 +131,14 @@
             sns_recurse.discard(ident)
 
     def __eq__(self, other):
-        return (issubclass(type(other), SimpleNamespace) and
-                self.__dict__ == other.__dict__)
+        if issubclass(type(other), SimpleNamespace):
+            return self.__dict__ == other.__dict__
+        return NotImplemented
+
+    def __ne__(self, other):
+        if issubclass(type(other), SimpleNamespace):
+            return self.__dict__ != other.__dict__
+        return NotImplemented
 
 sns_recurse = set()
 


More information about the pypy-commit mailing list