mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
Temporary fix to valid_identifier().
This commit is contained in:
parent
2f3941d743
commit
c6e8fd6de7
1 changed files with 7 additions and 8 deletions
15
Lib/re.py
15
Lib/re.py
|
@ -231,16 +231,15 @@ def escape(pattern):
|
||||||
result.append(char)
|
result.append(char)
|
||||||
return string.join(result, '')
|
return string.join(result, '')
|
||||||
|
|
||||||
|
_idprog = None
|
||||||
def valid_identifier(id):
|
def valid_identifier(id):
|
||||||
import string
|
global _idprog
|
||||||
if len(id) == 0:
|
if not _idprog:
|
||||||
return 0
|
_idprog = compile(r"[a-zA-Z_]\w*$")
|
||||||
if id[0] not in string.letters+'_':
|
if _idprog.match(id):
|
||||||
return 0
|
|
||||||
for char in id[1:]:
|
|
||||||
if not syntax_table[char] & word:
|
|
||||||
return 0
|
|
||||||
return 1
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
def compile(pattern, flags=0):
|
def compile(pattern, flags=0):
|
||||||
groupindex={}
|
groupindex={}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue