Vadim Pushtaev <[email protected]> added the comment:
Here is what I learned:
1) Nothing is wrong with that "tuple.__new__(sys.flags) is not safe" part.
`__new__` is deleted from `type(sys.flags)`, so parent's `__new__` is called.
`tuple` is indeed a base class for `type(sys.flags)`.
2) Another part where we recommend to use "sys.flags.__new__()" doesn't make
much sense, so I choose to delete this advice if there is no `__new__` in a
class.
3) This second part also may suggest a wrong class to call `__new__` from:
In [1]: from collections import namedtuple
In [2]: class A(namedtuple('A', 'z')):
...: pass
...:
In [3]: object.__new__(A)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-24eacd9ea752> in <module>()
----> 1 object.__new__(A)
TypeError: object.__new__(A) is not safe, use tuple.__new__()
This should be A.__new__(), not tuple.__new__().
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34284>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com