[pypy-commit] pypy py3.7: Fixed annotation errors related to fixed-sized lists, and added a test checking __orig_bases__ is only set when __bases__ gets changed through the __mro_entries__ mechanism
Yannick_Jadoul
pypy.commits at gmail.com
Sun Oct 6 10:40:34 EDT 2019
Author: Yannick Jadoul <yannick.jadoul at belgacom.net>
Branch: py3.7
Changeset: r97730:01b4c2af5928
Date: 2019-09-24 19:08 +0200
http://bitbucket.org/pypy/pypy/changeset/01b4c2af5928/
Log: Fixed annotation errors related to fixed-sized lists, and added a
test checking __orig_bases__ is only set when __bases__ gets changed
through the __mro_entries__ mechanism
diff --git a/pypy/module/__builtin__/compiling.py b/pypy/module/__builtin__/compiling.py
--- a/pypy/module/__builtin__/compiling.py
+++ b/pypy/module/__builtin__/compiling.py
@@ -97,7 +97,7 @@
frame.exec_(w_prog, w_globals, w_locals)
def _update_bases(space, w_bases):
- bases_w = space.listview(w_bases)
+ bases_w = space.fixedview(w_bases)
new_bases_w = []
changed = False
for w_base in bases_w:
@@ -112,7 +112,7 @@
new_bases_w.append(w_base)
if not changed:
return bases_w
- return new_bases_w
+ return new_bases_w[:]
def build_class(space, w_func, w_name, __args__):
from pypy.objspace.std.typeobject import _calculate_metaclass, W_TypeObject
@@ -122,7 +122,7 @@
orig_bases_w, kwds_w = __args__.unpack()
w_orig_bases = space.newtuple(orig_bases_w)
bases_w = _update_bases(space, w_orig_bases)
- w_bases = space.newtuple(bases_w[:])
+ w_bases = space.newtuple(bases_w)
w_meta = kwds_w.pop('metaclass', None)
if w_meta is not None:
isclass = space.isinstance_w(w_meta, space.w_type)
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
@@ -1483,6 +1483,10 @@
assert TestMixed.__bases__ == (BaseC, BaseA, BaseB, BaseD)
assert len(TestMixed.__orig_bases__) == 4
assert isinstance(TestMixed.__orig_bases__[1], ProxyAB) and isinstance(TestMixed.__orig_bases__[3], ProxyNone)
+
+ class TestNoOrigBases(BaseA, BaseB): pass
+ assert TestNoOrigBases.__bases__ == (BaseA, BaseB)
+ assert not hasattr(TestNoOrigBases, '__orig_bases__')
"""
More information about the pypy-commit
mailing list