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
bbb8ade9
Commit
bbb8ade9
authored
Mar 16, 2015
by
Robert Collins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23631: Fix traceback.format_list when a traceback has been mutated.
parent
93f4d4c1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
5 deletions
+21
-5
Lib/test/test_traceback.py
Lib/test/test_traceback.py
+9
-1
Lib/traceback.py
Lib/traceback.py
+10
-4
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_traceback.py
View file @
bbb8ade9
...
...
@@ -555,6 +555,14 @@ class TestStack(unittest.TestCase):
[
' File "foo.py", line 1, in fred
\
n
line
\
n
'
],
s
.
format
())
def
test_from_list_edited_stack
(
self
):
s
=
traceback
.
StackSummary
.
from_list
([(
'foo.py'
,
1
,
'fred'
,
'line'
)])
s
[
0
]
=
(
'foo.py'
,
2
,
'fred'
,
'line'
)
s2
=
traceback
.
StackSummary
.
from_list
(
s
)
self
.
assertEqual
(
[
' File "foo.py", line 2, in fred
\
n
line
\
n
'
],
s2
.
format
())
def
test_format_smoke
(
self
):
# For detailed tests see the format_list tests, which consume the same
# code.
...
...
@@ -585,7 +593,7 @@ class TestStack(unittest.TestCase):
traceback
.
walk_stack
(
None
),
capture_locals
=
True
,
limit
=
1
)
s
=
some_inner
(
3
,
4
)
self
.
assertEqual
(
[
' File "'
+
__file__
+
'", line 5
85
, '
[
' File "'
+
__file__
+
'", line 5
93
, '
'in some_inner
\
n
'
' traceback.walk_stack(None), capture_locals=True, limit=1)
\
n
'
' a = 1
\
n
'
...
...
Lib/traceback.py
View file @
bbb8ade9
...
...
@@ -348,10 +348,16 @@ class StackSummary(list):
This method supports the older Python API. Each tuple should be a
4-tuple with (filename, lineno, name, line) elements.
"""
if
isinstance
(
a_list
,
StackSummary
):
return
StackSummary
(
a_list
)
# While doing a fast-path check for isinstance(a_list, StackSummary) is
# appealing, idlelib.run.cleanup_traceback and other similar code may
# break this by making arbitrary frames plain tuples, so we need to
# check on a frame by frame basis.
result
=
StackSummary
()
for
filename
,
lineno
,
name
,
line
in
a_list
:
for
frame
in
a_list
:
if
isinstance
(
frame
,
FrameSummary
):
result
.
append
(
frame
)
else
:
filename
,
lineno
,
name
,
line
=
frame
result
.
append
(
FrameSummary
(
filename
,
lineno
,
name
,
line
=
line
))
return
result
...
...
Misc/NEWS
View file @
bbb8ade9
...
...
@@ -18,6 +18,8 @@ Core and Builtins
Library
-------
- Issue #23631: Fix traceback.format_list when a traceback has been mutated.
- Issue #23568: Add rdivmod support to MagicMock() objects.
Patch by Håkan Lövdahl.
...
...
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