Message323110
Looking at the code in https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Python/sysmodule.c#L2360, I think the underlying problem here is that the code to make these PyStructSequence subclasses uninstantiable isn't really right - rather than clearing those fields in the subclass (which still allows dynamic method lookup to fall back to the parent class, even though fast C level dispatch fails), it would be more consistent and reliable to replace them with implementations that always raise a TypeError with a suitable message.
(An alternative may be to implement the same behaviour as the builtin singleton types used for None and Ellipsis: replace __new__ with an implementation that always returns the original singleton instance. However, there isn't a compelling use case, so raising a descriptive exception along the lines of what ppperry suggests seems most appropriate) |
|
Date |
User |
Action |
Args |
2018-08-04 15:44:41 | ncoghlan | set | recipients:
+ ncoghlan, serhiy.storchaka, ppperry, Vadim Pushtaev |
2018-08-04 15:44:41 | ncoghlan | set | messageid: <1533397481.74.0.56676864532.issue34284@psf.upfronthosting.co.za> |
2018-08-04 15:44:41 | ncoghlan | link | issue34284 messages |
2018-08-04 15:44:41 | ncoghlan | create | |
|