Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ff4b63b8
Commit
ff4b63b8
authored
Aug 04, 2006
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1531405, format_exception no longer raises an exception if
str(exception) raised an exception.
parent
4b8bd31e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
5 deletions
+51
-5
Lib/test/test_traceback.py
Lib/test/test_traceback.py
+13
-4
Lib/traceback.py
Lib/traceback.py
+6
-1
Misc/NEWS
Misc/NEWS
+32
-0
No files found.
Lib/test/test_traceback.py
View file @
ff4b63b8
...
@@ -130,15 +130,24 @@ def test():
...
@@ -130,15 +130,24 @@ def test():
def
test_string_exception1
(
self
):
def
test_string_exception1
(
self
):
str_type
=
"String Exception"
str_type
=
"String Exception"
err
=
traceback
.
format_exception_only
(
str_type
,
None
)
err
=
traceback
.
format_exception_only
(
str_type
,
None
)
self
.
assert
_
(
len
(
err
)
==
1
)
self
.
assert
Equal
(
len
(
err
),
1
)
self
.
assert
_
(
err
[
0
]
==
str_type
+
'
\
n
'
)
self
.
assert
Equal
(
err
[
0
],
str_type
+
'
\
n
'
)
def
test_string_exception2
(
self
):
def
test_string_exception2
(
self
):
str_type
=
"String Exception"
str_type
=
"String Exception"
str_value
=
"String Value"
str_value
=
"String Value"
err
=
traceback
.
format_exception_only
(
str_type
,
str_value
)
err
=
traceback
.
format_exception_only
(
str_type
,
str_value
)
self
.
assert_
(
len
(
err
)
==
1
)
self
.
assertEqual
(
len
(
err
),
1
)
self
.
assert_
(
err
[
0
]
==
str_type
+
': '
+
str_value
+
'
\
n
'
)
self
.
assertEqual
(
err
[
0
],
str_type
+
': '
+
str_value
+
'
\
n
'
)
def
test_format_exception_only_bad__str__
(
self
):
class
X
(
Exception
):
def
__str__
(
self
):
1
/
0
err
=
traceback
.
format_exception_only
(
X
,
X
())
self
.
assertEqual
(
len
(
err
),
1
)
str_value
=
'<unprintable %s object>'
%
X
.
__name__
self
.
assertEqual
(
err
[
0
],
X
.
__name__
+
': '
+
str_value
+
'
\
n
'
)
def
test_main
():
def
test_main
():
...
...
Lib/traceback.py
View file @
ff4b63b8
...
@@ -202,7 +202,12 @@ def format_exception_only(etype, value):
...
@@ -202,7 +202,12 @@ def format_exception_only(etype, value):
def
_format_final_exc_line
(
etype
,
value
):
def
_format_final_exc_line
(
etype
,
value
):
"""Return a list of a single line -- normal case for format_exception_only"""
"""Return a list of a single line -- normal case for format_exception_only"""
if
value
is
None
or
not
str
(
value
):
try
:
printable
=
value
is
None
or
not
str
(
value
)
except
:
printable
=
False
if
printable
:
line
=
"%s
\
n
"
%
etype
line
=
"%s
\
n
"
%
etype
else
:
else
:
line
=
"%s: %s
\
n
"
%
(
etype
,
_some_str
(
value
))
line
=
"%s: %s
\
n
"
%
(
etype
,
_some_str
(
value
))
...
...
Misc/NEWS
View file @
ff4b63b8
...
@@ -4,6 +4,38 @@ Python News
...
@@ -4,6 +4,38 @@ Python News
(
editors
:
check
NEWS
.
help
for
information
about
editing
NEWS
using
ReST
.)
(
editors
:
check
NEWS
.
help
for
information
about
editing
NEWS
using
ReST
.)
What
's New in Python 2.5 release candidate 1?
=============================================
*Release date: XX-AUG-2006*
Core and builtins
-----------------
Library
-------
- Bug #1531405, format_exception no longer raises an exception if
str(exception) raised an exception.
Extension Modules
-----------------
Tests
-----
Build
-----
Mac
---
What'
s
New
in
Python
2.5
beta
3
?
What'
s
New
in
Python
2.5
beta
3
?
================================
================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment