diff options
-rw-r--r-- | Lib/hotshot/log.py | 5 | ||||
-rw-r--r-- | Lib/test/test_hotshot.py | 14 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Objects/stringobject.c | 4 |
4 files changed, 22 insertions, 3 deletions
diff --git a/Lib/hotshot/log.py b/Lib/hotshot/log.py index 99d0729..b7ce259 100644 --- a/Lib/hotshot/log.py +++ b/Lib/hotshot/log.py @@ -106,7 +106,10 @@ class LogReader: return what, t, tdelta if what == WHAT_EXIT: - return what, self._pop(), tdelta + try: + return what, self._pop(), tdelta + except IndexError: + raise StopIteration if what == WHAT_LINENO: filename, firstlineno, funcname = self._stack[-1] diff --git a/Lib/test/test_hotshot.py b/Lib/test/test_hotshot.py index fa6b2f1..bc499bb 100644 --- a/Lib/test/test_hotshot.py +++ b/Lib/test/test_hotshot.py @@ -10,6 +10,7 @@ import gc from test import test_support from hotshot.log import ENTER, EXIT, LINE +from hotshot import stats def shortfilename(fn): @@ -136,6 +137,19 @@ class HotShotTestCase(unittest.TestCase): emptyfile.close() gc.collect() + def test_load_stats(self): + def start(prof): + prof.start() + # Make sure stats can be loaded when start and stop of profiler + # are not executed in the same stack frame. + profiler = self.new_profiler() + start(profiler) + profiler.stop() + profiler.close() + stats.load(self.logfn) + os.unlink(self.logfn) + + def test_main(): test_support.run_unittest(HotShotTestCase) @@ -89,6 +89,8 @@ C-API Library ------- +- Issue #1019882: Fix IndexError when loading certain hotshot stats. + - Issue #8397: Raise an error when attempting to mix iteration and regular reads on a BZ2File object, rather than returning incorrect results. diff --git a/Objects/stringobject.c b/Objects/stringobject.c index f8f6cef..e37b579 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -3959,7 +3959,7 @@ string_getnewargs(PyStringObject *v) #include "stringlib/string_format.h" PyDoc_STRVAR(format__doc__, -"S.format(*args, **kwargs) -> unicode\n\ +"S.format(*args, **kwargs) -> string\n\ \n\ "); @@ -3993,7 +3993,7 @@ done: } PyDoc_STRVAR(p_format__doc__, -"S.__format__(format_spec) -> unicode\n\ +"S.__format__(format_spec) -> string\n\ \n\ "); |