[pypy-commit] pypy py3.5: Refinement of c1fb69da92dc
arigo
pypy.commits at gmail.com
Wed Aug 23 12:01:34 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r92226:e8a566e9fcd9
Date: 2017-08-23 18:00 +0200
http://bitbucket.org/pypy/pypy/changeset/e8a566e9fcd9/
Log: Refinement of c1fb69da92dc
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
@@ -1303,6 +1303,27 @@
assert found == [1]
"""
+ def test_incomplete_extend_2(self): """
+ # Same as test_incomplete_extend, with multiple inheritance
+ class M(type):
+ def mro(cls):
+ if cls.__mro__ is None and cls.__name__ == 'Second':
+ try:
+ class X(First, cls):
+ pass
+ except TypeError:
+ found.append(1)
+ return type.mro(cls)
+ found = []
+ class Base(metaclass=M):
+ pass
+ class First(Base):
+ pass
+ class Second(Base):
+ pass
+ assert found == [1]
+ """
+
class AppTestWithMethodCacheCounter:
spaceconfig = {"objspace.std.withmethodcachecounter": True}
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
@@ -1036,6 +1036,9 @@
for w_candidate in bases_w:
if not isinstance(w_candidate, W_TypeObject):
continue
+ if not w_candidate.hasmro:
+ raise oefmt(w_candidate.space.w_TypeError,
+ "Cannot extend an incomplete type '%N'", w_candidate)
if w_bestbase is None:
w_bestbase = w_candidate # for now
continue
@@ -1055,9 +1058,6 @@
if w_bestbase is None:
raise oefmt(space.w_TypeError,
"a new-style class can't have only classic bases")
- if not w_bestbase.hasmro:
- raise oefmt(space.w_TypeError,
- "Cannot extend an incomplete type '%N'", w_bestbase)
if not w_bestbase.layout.typedef.acceptable_as_base_class:
raise oefmt(space.w_TypeError,
"type '%N' is not an acceptable base class", w_bestbase)
More information about the pypy-commit
mailing list