Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de> Branch: py3.6 Changeset: r94534:4ea0853cd59f Date: 2018-05-12 19:09 +0200 http://bitbucket.org/pypy/pypy/changeset/4ea0853cd59f/
Log: fill the classcell even earlier diff --git a/pypy/interpreter/test/test_compiler.py b/pypy/interpreter/test/test_compiler.py --- a/pypy/interpreter/test/test_compiler.py +++ b/pypy/interpreter/test/test_compiler.py @@ -1109,6 +1109,8 @@ assert f() == (4, 3, 2, 1), repr(f()) """ + # the following couple of tests are from test_super.py in the stdlib + def test_classcell(self): """ test_class = None @@ -1177,6 +1179,24 @@ """ + def test_class_mro(self): + """ + test_class = None + + class Meta(type): + def mro(self): + # self.f() doesn't work yet... + self.__dict__["f"]() + return super().mro() + + class A(metaclass=Meta): + def f(): + nonlocal test_class + test_class = __class__ + + assert test_class is A + """ + class AppTestOptimizer(object): def setup_class(cls): 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 @@ -803,14 +803,16 @@ key = space.text_w(w_key) dict_w[key] = space.getitem(w_dict, w_key) w_type = space.allocate_instance(W_TypeObject, w_typetype) - W_TypeObject.__init__(w_type, space, name, bases_w or [space.w_object], - dict_w, is_heaptype=True) # store the w_type in __classcell__ w_classcell = dict_w.get("__classcell__", None) if w_classcell: _store_type_in_classcell(space, w_type, w_classcell, dict_w) + W_TypeObject.__init__(w_type, space, name, bases_w or [space.w_object], + dict_w, is_heaptype=True) + + w_type.ready() _set_names(space, w_type) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit