[Python-bugs-list] [ python-Bugs-472234 ] type(obj) calls type->tp_init
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 17 Oct 2001 13:45:17 -0700
Bugs item #472234, was opened at 2001-10-17 13:45
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=472234&group_id=5470
Category: Type/class unification
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Roeland Rengelink (rengelink)
Assigned to: Guido van Rossum (gvanrossum)
Summary: type(obj) calls type->tp_init
Initial Comment:
In 2.2a4 Consider:
class Meta(type):
def __init__(self, *args):
print 'Meta.__init__ called'
class Object(object):
__metaclass__ = Meta
obj = Object()
print type(obj)
will print
Meta.__init__ called
Meta.__init__ called
<class Object.....>
The second call to Meta.__init__ results from the
type(obj) call. This is because type(obj) is special
cased in type_new(...) rather than type_call(...).
Although it's rather useless to define an __init__ in a
class derived from type (for metaclasses it's a better
idea to override __new__). I do think the call of
Meta.__init__ in type(obj) is a bug.
Thanks,
Roeland
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=472234&group_id=5470