Commit 5f72af23 authored by Ross Patterson's avatar Ross Patterson

Fixed the usage of pstats.Stats() output stream. The

Control_Panel/DebugInfo/manage_profile ZMI view has been broken since
Python 2.5.  This breaks Python 2.4 compatibility when the
publisher-profile-file configuration option is set.  This also removes
some ugly sys.stdout hackery.
parent e4816be9
......@@ -11,6 +11,10 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed
++++++++++
- Fixed the usage of pstats.Stats() output stream. The
Control_Panel/DebugInfo/manage_profile ZMI view has been broken
since Python 2.5. This breaks Python 2.4 compatibility when the
publisher-profile-file configuration option is set.
2.12.13 (2010-11-06)
......
......@@ -15,7 +15,6 @@ __doc__="""System management components"""
__version__='$Revision: 1.94 $'[11:-2]
from cgi import escape
from cStringIO import StringIO
from logging import getLogger
import os
import sys
......@@ -232,17 +231,12 @@ class DebugManager(Item, Implicit):
stats=getattr(sys, '_ps_', None)
if stats is None:
return None
output=StringIO()
stdout=sys.stdout
if stripDirs:
from copy import copy; stats= copy(stats)
stats.strip_dirs()
stats.sort_stats(sort)
sys.stdout=output
getattr(stats,'print_%s' % mode)(limit)
sys.stdout.flush()
sys.stdout=stdout
return output.getvalue()
return stats.stream.getvalue()
def manage_getSysPath(self):
return list(sys.path)
......
......@@ -403,7 +403,9 @@ def publish_module_profiled(module_name, stdin=sys.stdin, stdout=sys.stdout,
result=sys._pr_
pobj.create_stats()
if _pstat is None:
_pstat=sys._ps_=pstats.Stats(pobj)
from cStringIO import StringIO
stream = StringIO()
_pstat = sys._ps_ = pstats.Stats(pobj, stream=stream)
else: _pstat.add(pobj)
finally:
_plock.release()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment