[pypy-commit] pypy py3.6: Don't inherit IS_ABSTRACT flag
rlamy
pypy.commits at gmail.com
Fri Aug 23 10:12:47 EDT 2019
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.6
Changeset: r97248:486a01a9aafe
Date: 2019-08-23 15:11 +0100
http://bitbucket.org/pypy/pypy/changeset/486a01a9aafe/
Log: Don't inherit IS_ABSTRACT flag
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
@@ -71,6 +71,22 @@
raises(AttributeError, getattr, type, "__abstractmethods__")
raises(TypeError, "int.__abstractmethods__ = ('abc', )")
+ def test_is_abstract_flag(self):
+ # IS_ABSTRACT flag should always be in sync with
+ # cls.__dict__['__abstractmethods__']
+ FLAG_IS_ABSTRACT = 1 << 20
+
+ class Base:
+ pass
+ Base.__abstractmethods__ = {'x'}
+ assert Base.__flags__ & FLAG_IS_ABSTRACT
+
+ class Derived(Base):
+ pass
+ assert not (Derived.__flags__ & FLAG_IS_ABSTRACT)
+ Derived.__abstractmethods__ = {'x'}
+ assert Derived.__flags__ & FLAG_IS_ABSTRACT
+
def test_attribute_error(self):
class X(object):
__module__ = 'test'
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
@@ -816,7 +816,7 @@
return space.call_function(newfunc, w_winner, w_name, w_bases, w_dict)
w_typetype = w_winner
- name = space.text_w(w_name)
+ name = space.text_w(w_name)
if '\x00' in name:
raise oefmt(space.w_ValueError, "type name must not contain null characters")
pos = surrogate_in_utf8(name)
@@ -1339,7 +1339,6 @@
if not isinstance(w_base, W_TypeObject):
continue
w_self.flag_cpytype |= w_base.flag_cpytype
- w_self.flag_abstract |= w_base.flag_abstract
if w_self.flag_map_or_seq == '?':
w_self.flag_map_or_seq = w_base.flag_map_or_seq
More information about the pypy-commit
mailing list