From: Tarek Ziadé Date: Tue, 31 Mar 2009 20:48:31 +0000 (+0000) Subject: using log.warn for sys.stderr X-Git-Tag: v2.7a1~1677 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7cd138bc2127079642ee8a3f2fa9d58c889dec0;p=python using log.warn for sys.stderr --- diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py index 012fca15b5..dfcbe23537 100644 --- a/Lib/distutils/cmd.py +++ b/Lib/distutils/cmd.py @@ -352,9 +352,8 @@ class Command: # -- 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) diff --git a/Lib/distutils/log.py b/Lib/distutils/log.py index fcaa545a79..6f949d5179 100644 --- a/Lib/distutils/log.py +++ b/Lib/distutils/log.py @@ -18,13 +18,14 @@ class Log: 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)