[Python-checkins] cpython (3.2): Issue #9871: Prevent IDLE 3 crash when given byte stings

ned.deily python-checkins at python.org
Wed Sep 14 23:57:30 CEST 2011


http://hg.python.org/cpython/rev/e74860883a9c
changeset: 72382:e74860883a9c
branch: 3.2
parent: 72377:0f1e8c246a7b
user: Ned Deily <nad at acm.org>
date: Wed Sep 14 14:49:14 2011 -0700
summary:
 Issue #9871: Prevent IDLE 3 crash when given byte stings
with invalid hex escape sequences, like b'\x0'.
(Original patch by Claudiu Popa.)
files:
 Lib/idlelib/PyShell.py | 6 +++---
 Lib/idlelib/ScriptBinding.py | 8 ++++----
 Misc/ACKS | 1 +
 Misc/NEWS | 4 ++++
 4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -643,9 +643,9 @@
 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
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/ScriptBinding.py
@@ -101,10 +101,10 @@
 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)
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -705,6 +705,7 @@
 Guilherme Polo
 Michael Pomraning
 Iustin Pop
+Claudiu Popa
 John Popplewell
 Amrit Prem
 Paul Prescod
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,10 @@
 Library
 -------
 
+- Issue #9871: Prevent IDLE 3 crash when given byte stings
+ with invalid hex escape sequences, like b'\x0'.
+ (Original patch by Claudiu Popa.)
+
 - Issue #8933: distutils' PKG-INFO files will now correctly report
 Metadata-Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is
 present.
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /