Probably should be:

    try:
        from hmac import compare_digest as is_equal
    except ImportError: # Python < 3.3
        def is_equal(lhs, rhs):
            ...