mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Use string.ascii_letters instead of string.letters (SF bug #226706).
Move computation of sets of characters out of the body of the function that uses them.
This commit is contained in:
parent
0f715d2aa1
commit
cd694c44a9
2 changed files with 9 additions and 3 deletions
|
@ -30,13 +30,16 @@ import string
|
|||
|
||||
oops = 'oops'
|
||||
|
||||
IDENTSTARTCHARS = string.ascii_letters + '_'
|
||||
IDENTCHARS = string.ascii_letters + string.digits + '_'
|
||||
|
||||
# Check that string is a legal C identifier
|
||||
def checkid(str):
|
||||
if not str: return 0
|
||||
if not str[0] in string.letters+'_':
|
||||
if not str[0] in IDENTSTARTCHARS:
|
||||
return 0
|
||||
for c in str[1:]:
|
||||
if not c in string.letters+string.digits+'_':
|
||||
if not c in IDENTCHARS:
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue