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