Message292185
| Author |
terry.reedy |
| Recipients |
SilentGhost, altvod, bob.ippolito, ezio.melotti, r.david.murray, rhettinger, serhiy.storchaka, terry.reedy |
| Date |
2017年04月23日.20:45:03 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1492980303.89.0.32087754995.issue27613@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Thank you Raymond. What I missed before is a) the OP's misnamed EmptyIterator is an iterable (possibly non-empty) but not an iterator, empty or otherwise, and b) a sequence __len__ that lies is just a bug. (So is a iterator that does not yield the contents of a collection.) A non-0 length(lst) is a promise that lst[0] exists. Depending on this is routine. If json.encoder line 296, 'for value in lst:' were replaced by the following, which should be equivalent,
for i in range(len(list)):
value = lst[i]
the encoding would die with IndexError.
The intention that buggy code should not cause a crash was met in this case. |
|