Message308596
I retested and iter(ob) (1) apparently raises 'not iterable' only when it can find neither __iter__ nor __getitem__. It (2) raises 'non-iterator', as above, when it finds __iter__, calls its, and get a non-iterator. (3) Exceptions in __iter__ are passed through. (If it finds and wraps __getitem__, errors only appear during iteration.)
The current patch for assignment unpacking catches case (1) with "v->ob_type->tp_iter == NULL && !PySequence_Check(v))". Removing this would catch case (2) and incidentally case (3) TypeErrors. Not catching user TypeErrors would require looking at the message. I intentionally am not proposing to remove the TypeError check.
Presuming the existence of a PyErr_' function to get exception messages, we could simply prefix the existing message with a short 'Cannot unpack. ' The same could be done for the other cases in msg307999, but I don't know if they are subject to the same need. |
|
Date |
User |
Action |
Args |
2017-12-19 00:17:04 | terry.reedy | set | recipients:
+ terry.reedy, rhettinger, eric.smith, steven.daprano, r.david.murray, serhiy.storchaka, Camion |
2017-12-19 00:17:04 | terry.reedy | set | messageid: <1513642624.82.0.213398074469.issue32259@psf.upfronthosting.co.za> |
2017-12-19 00:17:04 | terry.reedy | link | issue32259 messages |
2017-12-19 00:17:04 | terry.reedy | create | |
|