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
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)
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)
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)