Terry J. Reedy <tjre...@udel.edu> added the comment:

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__()

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type:  -> behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue14196>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to