예제 #1
0
파일: misc.py 프로젝트: StyXman/ayrton
def intern_if_common_string(space, w_const):
    # only intern identifier-like strings
    from pypy.objspace.std.unicodeobject import _isidentifier
    if (space.is_w(space.type(w_const), space.w_unicode) and
        _isidentifier(space.unicode_w(w_const))):
        return space.new_interned_w_str(w_const)
    return w_const
예제 #2
0
def intern_if_common_string(space, w_const):
    # only intern identifier-like strings
    from pypy.objspace.std.unicodeobject import _isidentifier
    if (space.is_w(space.type(w_const), space.w_unicode)
            and _isidentifier(space.unicode_w(w_const))):
        return space.new_interned_w_str(w_const)
    return w_const
예제 #3
0
def verify_identifier(token):
    # 1=ok; 0=not an identifier; -1=bad utf-8
    try:
        rutf8.check_utf8(token, False)
    except rutf8.CheckError:
        return -1
    from pypy.objspace.std.unicodeobject import _isidentifier
    return _isidentifier(token)
예제 #4
0
def verify_identifier(token):
    for c in token:
        if ord(c) > 0x80:
            break
    else:
        return True
    try:
        u = token.decode('utf-8')
    except UnicodeDecodeError:
        return False
    from pypy.objspace.std.unicodeobject import _isidentifier
    return _isidentifier(u)
예제 #5
0
def verify_identifier(token):
    # 1=ok; 0=not an identifier; -1=bad utf-8
    for c in token:
        if ord(c) >= 0x80:
            break
    else:
        return 1
    try:
        u = token.decode('utf-8')
    except UnicodeDecodeError:
        return -1
    from pypy.objspace.std.unicodeobject import _isidentifier
    return _isidentifier(u)