Message355665
Batuhan, thanks for the nudge. For the record ...
If __new__ were a normal instance method, then 'some_class.__new__()' would be a correct call, as 'some_class' would be passed to '__new__' as its first and perhaps only argument. But " __new__() is a static method (special-cased so you need not declare it as such)".
https://docs.python.org/3/reference/datamodel.html#object.__new__
Its special-casing makes it easy to forget that its first argument, a class, must be passed explicitly. Hence Xavier's comment.
In current 2.7.17 and 3.8 (for instance), with pdb left out of the picture, the missing cls argument results in
TypeError: object.__new__(): not enough arguments
When I pdb.run('A()') new and step, it catches the error and refuses to advance.
> <pyshell#10>(3)__new__()
(Pdb) s
TypeError: object.__new__(): not enough arguments
> <pyshell#10>(3)__new__() |
|
Date |
User |
Action |
Args |
2019-10-29 18:12:48 | terry.reedy | set | recipients:
+ terry.reedy, georg.brandl, xdegaye, tshepang, Simon.Chopin, BTaskaya |
2019-10-29 18:12:48 | terry.reedy | set | messageid: <1572372768.41.0.308607852532.issue14196@roundup.psfhosted.org> |
2019-10-29 18:12:48 | terry.reedy | link | issue14196 messages |
2019-10-29 18:12:48 | terry.reedy | create | |
|