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 christian.heimes
Recipients christian.heimes, pitrou, serhiy.storchaka
Date 2013-10-14.11:30:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1381750256.83.0.263124716214.issue19259@psf.upfronthosting.co.za>
In-reply-to
Content
The operator module doesn't have a Python implementation of _compare_digest. This code mimicks the C code:

def _compare_digest(a, b):
    if isinstance(a, str) and isinstance(b, str):
        a = a.encode("ascii")
        b = b.encode("ascii")
    a = memoryview(a)
    len_a = len(a)
    right = memoryview(b)
    len_b = len(right)
    if len_a == len_b:
        result = 0
        left = a
    # loop count depends on length of b
    if len_a != len_b:
        result = 1
        left = b
    for l, r in zip(left, right):
        result |= l ^ r
    return result == 0
History
Date User Action Args
2013-10-14 11:30:56christian.heimessetrecipients: + christian.heimes, pitrou, serhiy.storchaka
2013-10-14 11:30:56christian.heimessetmessageid: <1381750256.83.0.263124716214.issue19259@psf.upfronthosting.co.za>
2013-10-14 11:30:56christian.heimeslinkissue19259 messages
2013-10-14 11:30:56christian.heimescreate