Presumably some version of Python changed the way the Pstats class
works (at *instantiation* time it stores a copy of sys.stdout and uses
that).
diff --git a/paste/debug/profile.py b/paste/debug/profile.py
index 8e2d40a..aaf6249 100644
--- a/paste/debug/profile.py
+++ b/paste/debug/profile.py
@@ -74,9 +74,19 @@ class ProfileMiddleware(object):
stats = hotshot.stats.load(self.log_filename)
stats.strip_dirs()
stats.sort_stats('time', 'calls')
- output = capture_output(stats.print_stats, self.limit)
- output_callers = capture_output(
- stats.print_callers, self.limit)
+ if hasattr(stats, 'stream'):
+ oldstream = stats.stream
+ stats.stream = StringIO()
+ stats.print_stats(self.limit)
+ output = stats.stream.getvalue()
+ stats.stream = StringIO()
+ stats.print_callers(self.limit)
+ output_callers = stats.stream.getvalue()
+ stats.stream = oldstream
+ else:
+ output = capture_output(stats.print_stats, self.limit)
+ output_callers = capture_output(
+ stats.print_callers, self.limit)
body += '<pre style="%s">%s\n%s</pre>' % (
self.style, cgi.escape(output), cgi.escape(output_callers))
return [body]
--
Jon