diff options
author | Ned Deily <nad@acm.org> | 2011-09-14 21:49:14 (GMT) |
---|---|---|
committer | Ned Deily <nad@acm.org> | 2011-09-14 21:49:14 (GMT) |
commit | 79746426c439a8a163d95381ffffa1b2fd34348e (patch) | |
tree | b01c0863b76906fcfb638fd4128eca1647a6e804 /Lib | |
parent | 962055d3c658e9b2e75ba4c3682c3639eea9aed8 (diff) | |
download | cpython-79746426c439a8a163d95381ffffa1b2fd34348e.zip cpython-79746426c439a8a163d95381ffffa1b2fd34348e.tar.gz cpython-79746426c439a8a163d95381ffffa1b2fd34348e.tar.bz2 |
Issue #9871: Prevent IDLE 3 crash when given byte stings
with invalid hex escape sequences, like b'\x0'.
(Original patch by Claudiu Popa.)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/idlelib/PyShell.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/ScriptBinding.py | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index da74729..43e08f2 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -643,9 +643,9 @@ class ModifiedInterpreter(InteractiveInterpreter): text = tkconsole.text text.tag_remove("ERROR", "1.0", "end") type, value, tb = sys.exc_info() - msg = value.msg or "<no detail available>" - lineno = value.lineno or 1 - offset = value.offset or 0 + msg = getattr(value, 'msg', '') or value or "<no detail available>" + lineno = getattr(value, 'lineno', '') or 1 + offset = getattr(value, 'offset', '') or 0 if offset == 0: lineno += 1 #mark end of offending line if lineno == 1: diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py index 915e56e..26becce 100644 --- a/Lib/idlelib/ScriptBinding.py +++ b/Lib/idlelib/ScriptBinding.py @@ -101,10 +101,10 @@ class ScriptBinding: try: # If successful, return the compiled code return compile(source, filename, "exec") - except (SyntaxError, OverflowError) as value: - msg = value.msg or "<no detail available>" - lineno = value.lineno or 1 - offset = value.offset or 0 + except (SyntaxError, OverflowError, ValueError) as value: + msg = getattr(value, 'msg', '') or value or "<no detail available>" + lineno = getattr(value, 'lineno', '') or 1 + offset = getattr(value, 'offset', '') or 0 if offset == 0: lineno += 1 #mark end of offending line pos = "0.0 + %d lines + %d chars" % (lineno-1, offset-1) |