This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Vadim Pushtaev
Recipients Vadim Pushtaev, ppperry
Date 2018-07-30.23:40:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1532994012.91.0.56676864532.issue34284@psf.upfronthosting.co.za>
In-reply-to
Content
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__().
History
Date User Action Args
2018-07-30 23:40:12Vadim Pushtaevsetrecipients: + Vadim Pushtaev, ppperry
2018-07-30 23:40:12Vadim Pushtaevsetmessageid: <1532994012.91.0.56676864532.issue34284@psf.upfronthosting.co.za>
2018-07-30 23:40:12Vadim Pushtaevlinkissue34284 messages
2018-07-30 23:40:12Vadim Pushtaevcreate