Log message for revision 37343: Don't break if Python distros ship without profile support (Debian, Ubuntu).
Changed: U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/profiler.py -=- Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt 2005-07-19 21:50:53 UTC (rev 37342) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt 2005-07-20 07:32:43 UTC (rev 37343) @@ -1,4 +1,5 @@ Unreleased +- Don't break if Python distros ship without profile support (Debian, Ubuntu). - Functional.publish() would hang if it got a request_method argument other than GET or HEAD while omitting the stdin argument. - installProduct() now becomes a noop if ZopeTestCase did not apply its Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/profiler.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/profiler.py 2005-07-19 21:50:53 UTC (rev 37342) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/profiler.py 2005-07-20 07:32:43 UTC (rev 37343) @@ -12,14 +12,18 @@ ############################################################################## """Profiling support for ZTC -$Id: profiler.py,v 1.3 2005/01/01 14:02:44 shh42 Exp $ +$Id$ """ import os, sys import interfaces -from profile import Profile -from pstats import Stats +# Some distros ship without profile +try: + from profile import Profile + from pstats import Stats +except ImportError: + def Profile(): pass _profile = Profile() _have_stats = 0 @@ -30,9 +34,12 @@ def runcall(*args, **kw): - global _have_stats - _have_stats = 1 - return apply(_profile.runcall, args, kw) + if _profile is None: + return apply(args[0], args[1:], kw) + else: + global _have_stats + _have_stats = 1 + return apply(_profile.runcall, args, kw) def print_stats(limit=limit, sort=sort, strip_dirs=strip_dirs): _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins