Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7974642

Browse files
committed
Issue #9871: Prevent IDLE 3 crash when given byte stings
with invalid hex escape sequences, like b'\x0'. (Original patch by Claudiu Popa.)
1 parent 962055d commit 7974642

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

Lib/idlelib/PyShell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,9 @@ def showsyntaxerror(self, filename=None):
643643
text = tkconsole.text
644644
text.tag_remove("ERROR", "1.0", "end")
645645
type, value, tb = sys.exc_info()
646-
msg = value.msg or "<no detail available>"
647-
lineno = value.lineno or 1
648-
offset = value.offset or 0
646+
msg = getattr(value, 'msg', '') or value or "<no detail available>"
647+
lineno = getattr(value, 'lineno', '') or 1
648+
offset = getattr(value, 'offset', '') or 0
649649
if offset == 0:
650650
lineno += 1 #mark end of offending line
651651
if lineno == 1:

Lib/idlelib/ScriptBinding.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ def checksyntax(self, filename):
101101
try:
102102
# If successful, return the compiled code
103103
return compile(source, filename, "exec")
104-
except (SyntaxError, OverflowError) as value:
105-
msg = value.msg or "<no detail available>"
106-
lineno = value.lineno or 1
107-
offset = value.offset or 0
104+
except (SyntaxError, OverflowError, ValueError) as value:
105+
msg = getattr(value, 'msg', '') or value or "<no detail available>"
106+
lineno = getattr(value, 'lineno', '') or 1
107+
offset = getattr(value, 'offset', '') or 0
108108
if offset == 0:
109109
lineno += 1 #mark end of offending line
110110
pos = "0.0 + %d lines + %d chars" % (lineno-1, offset-1)

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ Jean-François Piéronne
705705
Guilherme Polo
706706
Michael Pomraning
707707
Iustin Pop
708+
Claudiu Popa
708709
John Popplewell
709710
Amrit Prem
710711
Paul Prescod

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Core and Builtins
2525
Library
2626
-------
2727

28+
- Issue #9871: Prevent IDLE 3 crash when given byte stings
29+
with invalid hex escape sequences, like b'\x0'.
30+
(Original patch by Claudiu Popa.)
31+
2832
- Issue #8933: distutils' PKG-INFO files will now correctly report
2933
Metadata-Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is
3034
present.

0 commit comments

Comments
 (0)