Kaydet (Commit) cd694c44 authored tarafından Fred Drake's avatar Fred Drake

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.
üst 0f715d2a
...@@ -36,6 +36,9 @@ def linecache_checkcache(orig_checkcache=linecache.checkcache): ...@@ -36,6 +36,9 @@ def linecache_checkcache(orig_checkcache=linecache.checkcache):
linecache.checkcache = linecache_checkcache linecache.checkcache = linecache_checkcache
IDENTCHARS = string.ascii_letters + string.digits + "_"
# Note: <<newline-and-indent>> event is defined in AutoIndent.py # Note: <<newline-and-indent>> event is defined in AutoIndent.py
#$ event <<plain-newline-and-indent>> #$ event <<plain-newline-and-indent>>
...@@ -217,7 +220,7 @@ class ModifiedInterpreter(InteractiveInterpreter): ...@@ -217,7 +220,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
text.tag_add("ERROR", pos) text.tag_add("ERROR", pos)
text.see(pos) text.see(pos)
char = text.get(pos) char = text.get(pos)
if char and char in string.letters + string.digits + "_": if char and char in IDENTCHARS:
text.tag_add("ERROR", pos + " wordstart", pos) text.tag_add("ERROR", pos + " wordstart", pos)
self.tkconsole.resetoutput() self.tkconsole.resetoutput()
self.write("SyntaxError: %s\n" % str(msg)) self.write("SyntaxError: %s\n" % str(msg))
......
...@@ -30,13 +30,16 @@ import string ...@@ -30,13 +30,16 @@ import string
oops = 'oops' oops = 'oops'
IDENTSTARTCHARS = string.ascii_letters + '_'
IDENTCHARS = string.ascii_letters + string.digits + '_'
# Check that string is a legal C identifier # Check that string is a legal C identifier
def checkid(str): def checkid(str):
if not str: return 0 if not str: return 0
if not str[0] in string.letters+'_': if not str[0] in IDENTSTARTCHARS:
return 0 return 0
for c in str[1:]: for c in str[1:]:
if not c in string.letters+string.digits+'_': if not c in IDENTCHARS:
return 0 return 0
return 1 return 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment