[issue34284] Nonsensical exception message when calling `__new__` on non-instaniable objects
Vadim Pushtaev
report at bugs.python.org
Tue Jul 31 04:17:57 EDT 2018
Vadim Pushtaev <pushtaev.vm at gmail.com> added the comment:
> See also issue31506
Okay, I admit, reporting `tuple.__new__` instead of `sys.flags` is misleading.
But what about this?
> `tuple.__new__(NamedTuple)` works, and produces a namedtuple object, so tuple.__new__ is what the error should point to.
Isn't it the same? Why should we say anything about `tuple` if a user wants A? This looks similar to 31506:
>>> from collections import namedtuple
>>> class A(namedtuple('x', 'x')):
... pass
...
>>> A.__new__(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in __new__
TypeError: tuple.__new__(X): X is not a type object (int)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34284>
_______________________________________
More information about the Python-bugs-list
mailing list