Message292185
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. |
|
Date |
User |
Action |
Args |
2017-04-23 20:45:03 | terry.reedy | set | recipients:
+ terry.reedy, rhettinger, bob.ippolito, ezio.melotti, r.david.murray, SilentGhost, serhiy.storchaka, altvod |
2017-04-23 20:45:03 | terry.reedy | set | messageid: <1492980303.89.0.32087754995.issue27613@psf.upfronthosting.co.za> |
2017-04-23 20:45:03 | terry.reedy | link | issue27613 messages |
2017-04-23 20:45:03 | terry.reedy | create | |
|