[Python-checkins] r70885 - in python/trunk/Lib/distutils: cmd.py log.py

tarek.ziade python-checkins at python.org
Tue Mar 31 22:48:31 CEST 2009


Author: tarek.ziade
Date: Tue Mar 31 22:48:31 2009
New Revision: 70885
Log:
using log.warn for sys.stderr
Modified:
 python/trunk/Lib/distutils/cmd.py
 python/trunk/Lib/distutils/log.py
Modified: python/trunk/Lib/distutils/cmd.py
==============================================================================
--- python/trunk/Lib/distutils/cmd.py	(original)
+++ python/trunk/Lib/distutils/cmd.py	Tue Mar 31 22:48:31 2009
@@ -352,9 +352,8 @@
 # -- External world manipulation -----------------------------------
 
 def warn (self, msg):
- sys.stderr.write("warning: %s: %s\n" %
- (self.get_command_name(), msg))
-
+ log.warn("warning: %s: %s\n" %
+ (self.get_command_name(), msg))
 
 def execute (self, func, args, msg=None, level=1):
 util.execute(func, args, msg, dry_run=self.dry_run)
Modified: python/trunk/Lib/distutils/log.py
==============================================================================
--- python/trunk/Lib/distutils/log.py	(original)
+++ python/trunk/Lib/distutils/log.py	Tue Mar 31 22:48:31 2009
@@ -18,13 +18,14 @@
 
 def _log(self, level, msg, args):
 if level >= self.threshold:
- if not args:
- # msg may contain a '%'. If args is empty,
- # don't even try to string-format
- print msg
+ if args:
+ msg = msg % args
+ if level in (WARN, ERROR, FATAL):
+ stream = sys.stderr
 else:
- print msg % args
- sys.stdout.flush()
+ stream = sys.stdout
+ stream.write('%s\n' % msg)
+ stream.flush()
 
 def log(self, level, msg, *args):
 self._log(level, msg, args)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /