mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
SF 747667 Error Doesn't Decolorize
Also improved error notification if Tabnanny detects a TokenError. M ScriptBinding
This commit is contained in:
parent
d2f4861a0b
commit
3f8ace9a0f
1 changed files with 6 additions and 1 deletions
|
@ -69,7 +69,10 @@ class ScriptBinding:
|
||||||
try:
|
try:
|
||||||
tabnanny.process_tokens(tokenize.generate_tokens(f.readline))
|
tabnanny.process_tokens(tokenize.generate_tokens(f.readline))
|
||||||
except tokenize.TokenError, msg:
|
except tokenize.TokenError, msg:
|
||||||
self.errorbox("Token error", "Token error:\n%s" % msg)
|
msgtxt, (lineno, start) = msg
|
||||||
|
self.editwin.gotoline(lineno)
|
||||||
|
self.errorbox("Tabnanny Tokenizing Error",
|
||||||
|
"Token Error: %s" % msgtxt)
|
||||||
return False
|
return False
|
||||||
except tabnanny.NannyNag, nag:
|
except tabnanny.NannyNag, nag:
|
||||||
# The error messages from tabnanny are too confusing...
|
# The error messages from tabnanny are too confusing...
|
||||||
|
@ -86,6 +89,8 @@ class ScriptBinding:
|
||||||
source = re.sub(r"\r\n", "\n", source)
|
source = re.sub(r"\r\n", "\n", source)
|
||||||
if source and source[-1] != '\n':
|
if source and source[-1] != '\n':
|
||||||
source = source + '\n'
|
source = source + '\n'
|
||||||
|
text = self.editwin.text
|
||||||
|
text.tag_remove("ERROR", "1.0", "end")
|
||||||
try:
|
try:
|
||||||
# If successful, return the compiled code
|
# If successful, return the compiled code
|
||||||
return compile(source, filename, "exec")
|
return compile(source, filename, "exec")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue