Terry J. Reedy added the comment: 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27613> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com