def bord(c):
    """In Python2, one calls ord(buf[i]) to get the i-th byte of
       a bytestring. In Python3, buf[i] already returns an int.
       Call bord(buf[i]) to achieve portability."""
    if isinstance(c, int):
        return c
    return ord(c)
