Exemplo n.º 1
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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)