Author: Armin Rigo <ar...@tunes.org>
Branch: py3k
Changeset: r87310:29e007fd6daa
Date: 2016-09-22 11:29 +0200
http://bitbucket.org/pypy/pypy/changeset/29e007fd6daa/

Log:    backport 146f531d6c86

diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -1391,3 +1391,7 @@
         assert not self.compares_by_identity(X)
         del X.__eq__
         assert self.compares_by_identity(X)
+
+    def test_duplicate_slot_name(self):
+        class X:   # does not raise
+            __slots__ = 'a', 'a'
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -1107,7 +1107,10 @@
         w_self.dict_w[slot_name] = space.wrap(member)
         return True
     else:
-        # never returns False, but that's to minimize the diff with pypy2
+        w_prev = w_self.dict_w[slot_name]
+        if isinstance(w_prev, Member) and w_prev.w_cls is w_self:
+            return False   # special case: duplicate __slots__ entry, ignored
+                           # (e.g. occurs in datetime.py, fwiw)
         raise oefmt(space.w_ValueError,
                     "'%8' in __slots__ conflicts with class variable",
                     slot_name)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to