[Python-checkins] r43529 - python/trunk/Lib/distutils/log.py

Thomas Wouters thomas at python.org
Sat Apr 1 16:43:23 CEST 2006


On 4/1/06, georg.brandl <python-checkins at python.org> wrote:
>
> Author: georg.brandl
> Date: Sat Apr  1 09:46:54 2006
> New Revision: 43529
>
> Modified:
>    python/trunk/Lib/distutils/log.py
> Log:
> Bug #1458017: make distutils.Log._log more forgiving when passing in
> msg strings with '%', but without format args.


I'm not sure if this is the right thing to do. It may be more forgiving, but
anyone who passes a string to a function that expects a format shouldn't be
looking for forgiveness. They should be made aware that %'s are special, or
they will be bitten by it when they _do_ pass arguments.


Modified: python/trunk/Lib/distutils/log.py
>
> ==============================================================================
> --- python/trunk/Lib/distutils/log.py   (original)
> +++ python/trunk/Lib/distutils/log.py   Sat Apr  1 09:46:54 2006
> @@ -20,7 +20,12 @@
>
>      def _log(self, level, msg, args):
>          if level >= self.threshold:
> -            print msg % args
> +            if not args:
> +                # msg may contain a '%'. If args is empty,
> +                # don't even try to string-format
> +                print msg
> +            else:
> +                print msg % args
>              sys.stdout.flush()
>
>      def log(self, level, msg, *args):



--
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-checkins/attachments/20060401/36e19ea5/attachment.htm 


More information about the Python-checkins mailing list