Issue638610
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2002-11-14 19:53 by shalabh, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Messages (7) | |||
---|---|---|---|
msg13224 - (view) | Author: Shalabh Chaturvedi (shalabh) | Date: 2002-11-14 19:53 | |
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? |
|||
msg13225 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2002-11-14 23:26 | |
Logged In: YES user_id=33168 Confirmed the behaviour in 2.2.2 and 2.3. |
|||
msg13226 - (view) | Author: Michael Hudson (mwh) | Date: 2002-11-15 10:14 | |
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... |
|||
msg13227 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2003-01-20 18:29 | |
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. |
|||
msg13228 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2003-02-12 22:36 | |
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. |
|||
msg13229 - (view) | Author: Michael Stone (mbrierst) | Date: 2003-02-13 05:28 | |
Logged In: YES user_id=670441 I agree that having separate __new__ and __init__ objects is a feature, but this can be preserved while also throwing an exception in the example given. When no __new__ OR __init__ has overriden the base object's new and init, arguments passed to them will be silently ignored. It seems preferable in that case to throw a type exception. If either one has been overridden, it will determine the class signature and throw an exception when appropriate. I submitted a patch to implement this as #685738. |
|||
msg13230 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2003-02-13 16:41 | |
Logged In: YES user_id=6380 This is nevertheless fixed now in CVS, thanks to SF fix 685738. :-) |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:53 | admin | set | github: 37474 |
2002-11-14 19:53:32 | shalabh | create |