[pypy-svn] r79433 - in pypy/branch/jit-free/pypy: jit/metainterp/test rlib

arigo at codespeak.net arigo at codespeak.net
Tue Nov 23 20:07:26 CET 2010


Author: arigo
Date: Tue Nov 23 20:07:24 2010
New Revision: 79433

Modified:
   pypy/branch/jit-free/pypy/jit/metainterp/test/test_logger.py
   pypy/branch/jit-free/pypy/rlib/debug.py
Log:
Remove one global that can be patched by tests,
and fix the only test that patches it.


Modified: pypy/branch/jit-free/pypy/jit/metainterp/test/test_logger.py
==============================================================================
--- pypy/branch/jit-free/pypy/jit/metainterp/test/test_logger.py	(original)
+++ pypy/branch/jit-free/pypy/jit/metainterp/test/test_logger.py	Tue Nov 23 20:07:24 2010
@@ -14,11 +14,20 @@
 
 def capturing(func, *args, **kwds):
     log_stream = StringIO()
-    debug._stderr = log_stream
+    class MyDebugLog:
+        def debug_print(self, *args):
+            for arg in args:
+                print >> log_stream, arg,
+            print >> log_stream
+        def debug_start(self, *args):
+            pass
+        def debug_stop(self, *args):
+            pass
     try:
+        debug._log = MyDebugLog()
         func(*args, **kwds)
     finally:
-        debug._stderr = sys.stderr
+        debug._log = None
     return log_stream.getvalue()
 
 class Logger(logger.Logger):

Modified: pypy/branch/jit-free/pypy/rlib/debug.py
==============================================================================
--- pypy/branch/jit-free/pypy/rlib/debug.py	(original)
+++ pypy/branch/jit-free/pypy/rlib/debug.py	Tue Nov 23 20:07:24 2010
@@ -53,13 +53,11 @@
 
 _log = None       # patched from tests to be an object of class DebugLog
                   # or compatible
-_stderr = sys.stderr   # alternatively, this is patched from tests
-                       # (redirects debug_print(), but not debug_start/stop)
 
 def debug_print(*args):
     for arg in args:
-        print >> _stderr, arg,
-    print >> _stderr
+        print >> sys.stderr, arg,
+    print >> sys.stderr
     if _log is not None:
         _log.debug_print(*args)
 



More information about the Pypy-commit mailing list