[Python-bugs-list] [ python-Bugs-638610 ] Instantiation init-less class with param
SourceForge.net
noreply@sourceforge.net
Wed, 12 Feb 2003 14:36:43 -0800
Bugs item #638610, was opened at 2002-11-14 14:53
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=638610&group_id=5470
Category: Type/class unification
Group: Python 2.3
>Status: Closed
>Resolution: Wont Fix
>Priority: 5
Submitted By: Shalabh Chaturvedi (shalabh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Instantiation init-less class with param
Initial Comment:
Instantiation new style __init__-less class with
parameters does not raise exception. Old style classes
raise TypeError: this constructor takes no arguments.
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit
(Intel)] on win32
>>> class C:
... pass
...
>>> c = C('extra', 'params')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: this constructor takes no arguments
>>>
>>> class C(object):
... pass
...
>>> c = C('whos','eating','my', 'params')
>>> c
<__main__.C object at 0x007A49B8>
>>>
Who?
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2003-02-12 17:36
Message:
Logged In: YES
user_id=6380
This is a feature. You inherit both a __new__ and a __init__
from object that ignore their arguments; this is so that you
can write a class that defines one but not the other, and
its signature then forces the class's signature.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2003-01-20 13:29
Message:
Logged In: YES
user_id=33168
Changed to 2.3 and bumped priority in the hopes that this
can/will be fixed for 2.3.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2002-11-15 05:14
Message:
Logged In: YES
user_id=6656
This is known behaviour (at least, I knew about it <wink>).
This is why:
>>> object(1,2,3)
<object object at 0x818dfb8>
I seem to recall discussion that this had to be left alone
in 2.2.X but should be fixed in 2.3...
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2002-11-14 18:26
Message:
Logged In: YES
user_id=33168
Confirmed the behaviour in 2.2.2 and 2.3.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=638610&group_id=5470