8000 Merged revisions 83531 via svnmerge from · python/cpython@e90bce7 · GitHub
[go: up one dir, main page]

Skip to content

Commit e90bce7

Browse files
committed
Merged revisions 83531 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83531 | georg.brandl | 2010-08-02 19:24:49 +0200 (Mo, 02 Aug 2010) | 1 line #7372: fix regression in pstats: a previous fix to handle cProfile data in add_callers broke handling of profile data. ........
1 parent bdeff47 commit e90bce7

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Lib/pstats.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,13 @@ def add_callers(target, source):
521521
new_callers[func] = caller
522522
for func, caller in source.items():
523523
if func in new_callers:
524-
new_callers[func] = tuple([i[0] + i[1] for i in
525-
zip(caller, new_callers[func])])
524+
if isinstance(caller, tuple):
525+
# format used by cProfile
526+
new_callers[func] = tuple([i[0] + i[1] for i in
527+
zip(caller, new_callers[func])])
528+
else:
529+
# format used by profile
530+
new_callers[func] += caller
526531
else:
527532
new_callers[func] = caller
528533
return new_callers

Lib/test/test_pstats.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ class AddCallersTestCase(unittest.TestCase):
1010
def test_combine_results(self):
1111
"""pstats.add_callers should combine the call results of both target
1212
and source by adding the call time. See issue1269."""
13+
# new format: used by the cProfile module
1314
target = {"a": (1, 2, 3, 4)}
1415
source = {"a": (1, 2, 3, 4), "b": (5, 6, 7, 8)}
1516
new_callers = pstats.add_callers(target, source)
1617
self.assertEqual(new_callers, {'a': (2, 4, 6, 8), 'b': (5, 6, 7, 8)})
18+
# old format: used by the profile module
19+
target = {"a": 1}
20+
source = {"a": 1, "b": 5}
21+
new_callers = pstats.add_callers(target, source)
22+
self.assertEqual(new_callers, {'a': 2, 'b': 5})
1723

1824

1925
def test_main():

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ C-API
8484
Library
8585
-------
8686

87+
- Issue #7372: Fix pstats regression when stripping paths from profile
88+
data generated with the profile module.
89+
8790
- Issue #4108: In urllib.robotparser, if there are multiple 'User-agent: *'
8891
entries, consider the first one.
8992

0 commit comments

Comments
 (0)
0