[Python-checkins] r62079 - sandbox/trunk/2to3/lib2to3/refactor.py

martin.v.loewis python-checkins at python.org
Mon Mar 31 07:18:16 CEST 2008


Author: martin.v.loewis
Date: Mon Mar 31 07:18:15 2008
New Revision: 62079

Modified:
   sandbox/trunk/2to3/lib2to3/refactor.py
Log:
Copy r62037 from trunk:
lib2to3 should install a logging handler only when run as a main
program,
not when used as a library.

This may please the buildbots, which fail when test_lib2to3 is run
before test_logging.


Modified: sandbox/trunk/2to3/lib2to3/refactor.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/refactor.py	(original)
+++ sandbox/trunk/2to3/lib2to3/refactor.py	Mon Mar 31 07:18:15 2008
@@ -28,15 +28,6 @@
 from . import fixes
 from . import pygram
 
-if sys.version_info < (2, 4):
-    hdlr = logging.StreamHandler()
-    fmt = logging.Formatter('%(name)s: %(message)s')
-    hdlr.setFormatter(fmt)
-    logging.root.addHandler(hdlr)
-else:
-    logging.basicConfig(format='%(name)s: %(message)s', level=logging.INFO)
-
-
 def main(args=None):
     """Main program.
 
@@ -73,6 +64,15 @@
         print >>sys.stderr, "Use --help to show usage."
         return 2
 
+    # Set up logging handler
+    if sys.version_info < (2, 4):
+        hdlr = logging.StreamHandler()
+        fmt = logging.Formatter('%(name)s: %(message)s')
+        hdlr.setFormatter(fmt)
+        logging.root.addHandler(hdlr)
+    else:
+        logging.basicConfig(format='%(name)s: %(message)s', level=logging.INFO)
+
     # Initialize the refactoring tool
     rt = RefactoringTool(options)
 


More information about the Python-checkins mailing list