Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r91617:70d5dcb50915 Date: 2017-06-17 16:01 +0200 http://bitbucket.org/pypy/pypy/changeset/70d5dcb50915/
Log: Fixes for test_descr diff --git a/lib-python/3/test/test_descr.py b/lib-python/3/test/test_descr.py --- a/lib-python/3/test/test_descr.py +++ b/lib-python/3/test/test_descr.py @@ -1663,7 +1663,8 @@ self.assertEqual(b.foo, 3) self.assertEqual(b.__class__, D) - @unittest.expectedFailure + #@unittest.expectedFailure --- on CPython. On PyPy, the test passes + @support.impl_detail(cpython=False) def test_bad_new(self): self.assertRaises(TypeError, object.__new__) self.assertRaises(TypeError, object.__new__, '') 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 @@ -477,7 +477,8 @@ a = 1 class mymeta(type): - def mro(self): + def mro(self, ignore=False): + assert ignore or self.__mro__ is None return [self, object] class B_mro(A_mro, metaclass=mymeta): @@ -485,7 +486,7 @@ assert B_mro.__bases__ == (A_mro,) assert B_mro.__mro__ == (B_mro, object) - assert B_mro.mro() == [B_mro, object] + assert B_mro.mro(ignore=True) == [B_mro, object] assert B_mro.b == 1 assert B_mro().b == 1 assert getattr(B_mro, 'a', None) == None 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 @@ -810,7 +810,10 @@ def descr_get__mro__(space, w_type): w_type = _check(space, w_type) - return space.newtuple(w_type.mro_w) + if w_type.hasmro: + return space.newtuple(w_type.mro_w) + else: + return space.w_None def descr_mro(space, w_type): """Return a type's method resolution order.""" @@ -1227,6 +1230,7 @@ ensure_module_attr(w_self) ensure_hash(w_self) w_self.mro_w = [] # temporarily + w_self.hasmro = False compute_mro(w_self) def ensure_static_new(w_self): @@ -1264,8 +1268,10 @@ w_mro = space.call_function(w_mro_meth) mro_w = space.fixedview(w_mro) w_self.mro_w = validate_custom_mro(space, mro_w) + w_self.hasmro = True return # done w_self.mro_w = w_self.compute_default_mro()[:] + w_self.hasmro = True def validate_custom_mro(space, mro_w): # do some checking here. Note that unlike CPython, strange MROs _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit