Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd694c4

Browse files
committed
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.
1 parent 0f715d2 commit cd694c4

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

Tools/idle/PyShell.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def linecache_checkcache(orig_checkcache=linecache.checkcache):
3636
linecache.checkcache = linecache_checkcache
3737

3838

39+
IDENTCHARS = string.ascii_letters + string.digits + "_"
40+
41+
3942
# Note: <<newline-and-indent>> event is defined in AutoIndent.py
4043

4144
#$ event <<plain-newline-and-indent>>
@@ -217,7 +220,7 @@ def showsyntaxerror(self, filename=None):
217220
text.tag_add("ERROR", pos)
218221
text.see(pos)
219222
char = text.get(pos)
220-
if char and char in string.letters + string.digits + "_":
223+
if char and char in IDENTCHARS:
221224
text.tag_add("ERROR", pos + " wordstart", pos)
222225
self.tkconsole.resetoutput()
223226
self.write("SyntaxError: %s\n" % str(msg))

Tools/modulator/modulator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@
3030

3131
oops = 'oops'
3232

33+
IDENTSTARTCHARS = string.ascii_letters + '_'
34+
IDENTCHARS = string.ascii_letters + string.digits + '_'
35+
3336
# Check that string is a legal C identifier
3437
def checkid(str):
3538
if not str: return 0
36-
if not str[0] in string.letters+'_':
39+
if not str[0] in IDENTSTARTCHARS:
3740
return 0
3841
for c in str[1:]:
39-
if not c in string.letters+string.digits+'_':
42+
if not c in IDENTCHARS:
4043
return 0
4144
return 1
4245

0 commit comments

Comments
 (0)