Message322695
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__(). |
|
Date |
User |
Action |
Args |
2018-07-30 23:40:12 | Vadim Pushtaev | set | recipients:
+ Vadim Pushtaev, ppperry |
2018-07-30 23:40:12 | Vadim Pushtaev | set | messageid: <1532994012.91.0.56676864532.issue34284@psf.upfronthosting.co.za> |
2018-07-30 23:40:12 | Vadim Pushtaev | link | issue34284 messages |
2018-07-30 23:40:12 | Vadim Pushtaev | create | |
|