diff options
author | Guido van Rossum <guido@python.org> | 2002-08-12 19:05:44 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-08-12 19:05:44 +0000 |
commit | ad47da072a436751c0cfd95a21eccea1c39b35f1 (patch) | |
tree | 7c9f38c7d45d06368e075a0c869d08186d9dd1ae /Python/codecs.c | |
parent | 115c888b97125e31851fc64cc0292c4fc3b122dd (diff) | |
download | cpython-git-ad47da072a436751c0cfd95a21eccea1c39b35f1.tar.gz |
Refactor how __dict__ and __weakref__ interact with __slots__.
1. You can now have __dict__ and/or __weakref__ in your __slots__
(before only __weakref__ was supported). This is treated
differently than before: it merely sets a flag that the object
should support the corresponding magic.
2. Dynamic types now always have descriptors __dict__ and __weakref__
thrust upon them. If the type in fact does not support one or the
other, that descriptor's __get__ method will raise AttributeError.
3. (This is the reason for all this; it fixes SF bug 575229, reported
by Cesar Douady.) Given this code:
class A(object): __slots__ = []
class B(object): pass
class C(A, B): __slots__ = []
the class object for C was broken; its size was less than that of
B, and some descriptors on B could cause a segfault. C now
correctly inherits __weakrefs__ and __dict__ from B, even though A
is the "primary" base (C.__base__ is A).
4. Some code cleanup, and a few comments added.
Diffstat (limited to 'Python/codecs.c')
0 files changed, 0 insertions, 0 deletions