Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(17)

Unified Diff: cherrypy/lib/profiler.py

Issue 2325: cherrypy: Profile viewer doesn't work with Python2.5 (Closed) SVN Base: http://svn.cherrypy.org/branches/cherrypy-2.x/
Patch Set: Created 1 year, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side by-side-diff with in-line comments
Download patch
« no previous file | no next file » | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cherrypy/lib/profiler.py
===================================================================
--- cherrypy/lib/profiler.py (Revision 1982)
+++ cherrypy/lib/profiler.py (Arbeitskopie)
@@ -87,15 +87,22 @@
def stats(self, filename, sortby='cumulative'):
"""stats(index) -> output of print_stats() for the given profile."""
- s = pstats.Stats(os.path.join(self.path, filename))
+ sio = StringIO.StringIO()
+ kwds = {}
+ if sys.version_info >= (2, 5):
+ kwds['stream'] = sio
+ s = pstats.Stats(os.path.join(self.path, filename), **kwds)
s.strip_dirs()
s.sort_stats(sortby)
- oldout = sys.stdout
- try:
- sys.stdout = sio = StringIO.StringIO()
- s.print_stats()
- finally:
- sys.stdout = oldout
+ if sys.version_info >= (2, 5):
+ s.print_stats()
+ else:
+ oldout = sys.stdout
+ try:
+ sys.stdout = sio
+ s.print_stats()
+ finally:
+ sys.stdout = oldout
response = sio.getvalue()
sio.close()
return response
« no previous file | no next file »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r483