cffi_utils/py2to3.py
def ord(x):
    '''
    x-->char (str of length 1)
    Returns-->int
        Behaves like PY2 ord() in PY2 or PY3
    if x is str of length > 1 or int > 256
        raises ValueError/TypeError is not SUPPRESS_ERRORS
    '''
    global _ord
    if isinstance(x, int):
        if x > 256:
            if not SUPPRESS_ERRORS:
                raise ValueError('ord() arg not in range(256)')
        return x % 256
    elif isinstance(x, bytes):
        x = fromBytes(x)
        if len(x) > 1:
            if SUPPRESS_ERRORS:
                x = x[0]
        return _ord(x)
    elif isinstance(x, str):
        if len(x) > 1:
            if SUPPRESS_ERRORS:
                x = x[0]
        return _ord(x)
    else:
        raise TypeError('Unknown type passed to ord: %s', str(type(x)))
def ord(x):
    '''
    x-->char (str of length 1)
    Returns-->int
        Behaves like PY2 ord() in PY2 or PY3
    if x is str of length > 1 or int > 256
        raises ValueError/TypeError is not SUPPRESS_ERRORS
    '''
    global _ord
    if isinstance(x, int):
        if x > 256:
            if not SUPPRESS_ERRORS:
                raise ValueError('ord() arg not in range(256)')
        return x % 256
    elif isinstance(x, bytes):
        x = fromBytes(x)
        if len(x) > 1:
            if SUPPRESS_ERRORS:
                x = x[0]
        return _ord(x)
    elif isinstance(x, str):
        if len(x) > 1:
            if SUPPRESS_ERRORS:
                x = x[0]
        return _ord(x)
    else:
        raise TypeError('Unknown type passed to ord: %s', str(type(x)))
def ord ( x ) : global _ord if isinstance ( x , int ) : if x > 256 : if not SUPPRESS_ERRORS : raise ValueError ( 'ord() arg not in range(256)' ) return x % 256 elif isinstance ( x , bytes ) : x = fromBytes ( x ) if len ( x ) > 1 : if SUPPRESS_ERRORS : x = x [ 0 ] return _ord ( x ) elif isinstance ( x , str ) : if len ( x ) > 1 : if SUPPRESS_ERRORS : x = x [ 0 ] return _ord ( x ) else : raise TypeError ( 'Unknown type passed to ord: %s' , str ( type ( x ) ) )
x-->char (str of length 1)
    Returns-->int
        Behaves like PY2 ord() in PY2 or PY3
    if x is str of length > 1 or int > 256
        raises ValueError/TypeError is not SUPPRESS_ERRORS
x -- > char ( str of length 1 ) Returns -- > int Behaves like PY2 ord () in PY2 or PY3 if x is str of length > 1 or int > 256 raises ValueError / TypeError is not SUPPRESS_ERRORS