[Python-checkins] r83491 - in python/branches/release26-maint: Lib/hotshot/log.py Lib/test/test_hotshot.py Misc/NEWS Objects/stringobject.c

georg.brandl python-checkins at python.org
Mon Aug 2 00:02:10 CEST 2010


Author: georg.brandl
Date: Mon Aug  2 00:02:09 2010
New Revision: 83491

Log:
Merged revisions 83354,83365 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint

........
  r83354 | georg.brandl | 2010-07-31 21:07:37 +0200 (Sa, 31 Jul 2010) | 1 line
  
  #9328: string format methods return strings.
........
  r83365 | georg.brandl | 2010-07-31 23:22:36 +0200 (Sa, 31 Jul 2010) | 1 line
  
  #1019882: if start() and stop() were not in the same stack frame, stats.load() would crash with IndexError.
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Lib/hotshot/log.py
   python/branches/release26-maint/Lib/test/test_hotshot.py
   python/branches/release26-maint/Misc/NEWS
   python/branches/release26-maint/Objects/stringobject.c

Modified: python/branches/release26-maint/Lib/hotshot/log.py
==============================================================================
--- python/branches/release26-maint/Lib/hotshot/log.py	(original)
+++ python/branches/release26-maint/Lib/hotshot/log.py	Mon Aug  2 00:02:09 2010
@@ -106,7 +106,10 @@
                 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]

Modified: python/branches/release26-maint/Lib/test/test_hotshot.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_hotshot.py	(original)
+++ python/branches/release26-maint/Lib/test/test_hotshot.py	Mon Aug  2 00:02:09 2010
@@ -10,6 +10,7 @@
 from test import test_support
 
 from hotshot.log import ENTER, EXIT, LINE
+from hotshot import stats
 
 
 def shortfilename(fn):
@@ -136,6 +137,19 @@
             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)
 

Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Mon Aug  2 00:02:09 2010
@@ -89,6 +89,8 @@
 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.
 

Modified: python/branches/release26-maint/Objects/stringobject.c
==============================================================================
--- python/branches/release26-maint/Objects/stringobject.c	(original)
+++ python/branches/release26-maint/Objects/stringobject.c	Mon Aug  2 00:02:09 2010
@@ -3959,7 +3959,7 @@
 #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 @@
 }
 
 PyDoc_STRVAR(p_format__doc__,
-"S.__format__(format_spec) -> unicode\n\
+"S.__format__(format_spec) -> string\n\
 \n\
 ");
 


More information about the Python-checkins mailing list