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 terry.reedy
Recipients Camion, eric.smith, r.david.murray, rhettinger, serhiy.storchaka, steven.daprano, terry.reedy
Date 2017-12-19.00:17:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513642624.82.0.213398074469.issue32259@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-12-19 00:17:04terry.reedysetrecipients: + terry.reedy, rhettinger, eric.smith, steven.daprano, r.david.murray, serhiy.storchaka, Camion
2017-12-19 00:17:04terry.reedysetmessageid: <1513642624.82.0.213398074469.issue32259@psf.upfronthosting.co.za>
2017-12-19 00:17:04terry.reedylinkissue32259 messages
2017-12-19 00:17:04terry.reedycreate