[Python-bugs-list] [ python-Bugs-486144 ] Uninitialized __slot__ vrbl is None

noreply@sourceforge.net noreply@sourceforge.net
Tue, 04 Dec 2001 08:23:58 -0800


Bugs item #486144, was opened at 2001-11-27 11:51
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=486144&group_id=5470

Category: Type/class unification
Group: Python 2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Uninitialized __slot__ vrbl is None

Initial Comment:
>>> class C(object):
...     __slots__ = ['a']
...
>>> c = C()
>>> print c.a
None
>>>

Nothing else in Python works like this -- a (possibly 
subclass of) NameError exception would be better.

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-04 08:23

Message:
Logged In: YES 
user_id=6380

Fixed in CVS as I described.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-11-27 18:45

Message:
Logged In: YES 
user_id=6380

While this is not normal for class instances, built-in types
have long had this behavior -- if a built-in type has an
object pointer attribute described by a structmember with
code T_OBJECT, it has this behavior (NULL is treated as None
rather than absent attribute).

I propose to add a T_OBJECT_EX structmember code, which
raises an exception for NULL instead of returning None. This
can then be used by the __slots__ code in typeobject.c.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=486144&group_id=5470