mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
There's now a new structmember code, T_OBJECT_EX, which is used for all __slot__ variables (except __weakref__, which has special behavior anyway). This new code raises AttributeError when the variable is NULL rather than converting NULL to None.
This commit is contained in:
parent
ebca9fc1ba
commit
6b70599450
3 changed files with 19 additions and 6 deletions
|
@ -978,19 +978,21 @@ def slots():
|
|||
__slots__ = ['a']
|
||||
x = C1()
|
||||
verify(not hasattr(x, "__dict__"))
|
||||
vereq(x.a, None)
|
||||
verify(not hasattr(x, "a"))
|
||||
x.a = 1
|
||||
vereq(x.a, 1)
|
||||
x.a = None
|
||||
veris(x.a, None)
|
||||
del x.a
|
||||
vereq(x.a, None)
|
||||
verify(not hasattr(x, "a"))
|
||||
|
||||
class C3(object):
|
||||
__slots__ = ['a', 'b', 'c']
|
||||
x = C3()
|
||||
verify(not hasattr(x, "__dict__"))
|
||||
verify(x.a is None)
|
||||
verify(x.b is None)
|
||||
verify(x.c is None)
|
||||
verify(not hasattr(x, 'a'))
|
||||
verify(not hasattr(x, 'b'))
|
||||
verify(not hasattr(x, 'c'))
|
||||
x.a = 1
|
||||
x.b = 2
|
||||
x.c = 3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue