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 bup
Recipients bup
Date 2018-09-29.09:29:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538213389.56.0.545547206417.issue34842@psf.upfronthosting.co.za>
In-reply-to
Content
internal_bisect_left and internal_bisect_right use PySequence_Size when a "hi" argument wasn't provided, which causes this silly error message:

    >>> bisect.bisect_right(dict.fromkeys(range(10)), 5)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: object of type 'dict' has no len()

They could use PyObject_Size and let PySequence_GetItem in the loop catch the error:

    >>> bisect.bisect_right(dict.fromkeys(range(10)), 5, 0, 10)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'dict' object does not support indexing

Since that actually makes sense and is more efficient / less verbose than adding a PySequence_Check.
History
Date User Action Args
2018-09-29 09:29:49bupsetrecipients: + bup
2018-09-29 09:29:49bupsetmessageid: <1538213389.56.0.545547206417.issue34842@psf.upfronthosting.co.za>
2018-09-29 09:29:49buplinkissue34842 messages
2018-09-29 09:29:49bupcreate