[Zope-Checkins] SVN: Zope/trunk/lib/python/Testing/ZopeTestCase/ Don't break if Python distros ship without profile support (Debian, Ubuntu).

Stefan H. Holek stefan at epy.co.at
Wed Jul 20 03:36:07 EDT 2005


Log message for revision 37344:
  Don't break if Python distros ship without profile support (Debian, Ubuntu).
  

Changed:
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/profiler.py

-=-
Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt	2005-07-20 07:32:43 UTC (rev 37343)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt	2005-07-20 07:35:36 UTC (rev 37344)
@@ -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/trunk/lib/python/Testing/ZopeTestCase/profiler.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/profiler.py	2005-07-20 07:32:43 UTC (rev 37343)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/profiler.py	2005-07-20 07:35:36 UTC (rev 37344)
@@ -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):



More information about the Zope-Checkins mailing list