summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Tools/idle/PyShell.py5
-rwxr-xr-xTools/modulator/modulator.py7
2 files changed, 9 insertions, 3 deletions
diff --git a/Tools/idle/PyShell.py b/Tools/idle/PyShell.py
index bd34d18..03b4684 100644
--- a/Tools/idle/PyShell.py
+++ b/Tools/idle/PyShell.py
@@ -36,6 +36,9 @@ def linecache_checkcache(orig_checkcache=linecache.checkcache):
linecache.checkcache = linecache_checkcache
+IDENTCHARS = string.ascii_letters + string.digits + "_"
+
+
# Note: <<newline-and-indent>> event is defined in AutoIndent.py
#$ event <<plain-newline-and-indent>>
@@ -217,7 +220,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
text.tag_add("ERROR", pos)
text.see(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)
self.tkconsole.resetoutput()
self.write("SyntaxError: %s\n" % str(msg))
diff --git a/Tools/modulator/modulator.py b/Tools/modulator/modulator.py
index 23a2539..add8b6a 100755
--- a/Tools/modulator/modulator.py
+++ b/Tools/modulator/modulator.py
@@ -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