Commit 98f7b454 authored by Ross Patterson's avatar Ross Patterson

Merge Control_Panel/DebugInfo/manage_profile ZMI view fixes from

svn+ssh://svn.zope.org/repos/main/Zope/branches/2.12 r118262:118470
parent a290b1cb
......@@ -11,6 +11,13 @@ 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.
- Use cProfile where possible for the
Control_Panel/DebugInfo/manage_profile ZMI view.
Features Added
++++++++++++++
......
......@@ -232,17 +232,13 @@ 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
stats.stream = output = StringIO()
getattr(stats, 'print_%s' % mode)(limit)
return output.getvalue()
def manage_profile_reset(self):
......
......@@ -386,7 +386,12 @@ def pm(module_name, stdin, stdout, stderr,
def publish_module_profiled(module_name, stdin=sys.stdin, stdout=sys.stdout,
stderr=sys.stderr, environ=os.environ, debug=0,
request=None, response=None):
import profile, pstats
try:
import cProfile as profile
profile # pyflakes
except ImportError:
import profile
import pstats
global _pstat
_plock.acquire()
try:
......@@ -403,7 +408,7 @@ 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)
_pstat = sys._ps_ = pstats.Stats(pobj)
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