Bugs item #1458017, was opened at 2006-03-24 21:17
Message generated for change (Comment added) made by splitscreen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1458017&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Nobody/Anonymous (nobody)
Summary: Log._log needs to be more forgiving...

Initial Comment:
The _log method of distutils' Log class executes

    print msg % args

where args might be an empty tuple (the methods that
call _log all
have varargs signatures).  If that's the case and msg
happens to
contain a % sign, it barfs.  It should be more
forgiving, for
instance:

    def _log(self, level, msg, args):
        if level >= self.threshold:
            try:
                print msg % args
            except TypeError:
                if not args:
                    print msg
                else:
                    raise
            sys.stdout.flush()

I just corrected this locally for our 2.3 and 2.4
installations.  The
above is a bit ugly, but it does allow the common case
(msg contains a
% but an empty args list) to pass while still catching
most programmer
errors.  Distutils is trying to log this message (wrapped):

  gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes
  -fPIC -I/opt/app/mysql-5.0.19/include
  -I/opt/app/mysql-5.0.19/include
-I/opt/lang/python/include/python2.3
  -c _mysql.c -o build/temp.solaris-2.8-i86pc-2.3/_mysql.o
  -I/opt/app/mysql-5.0.19/include -xO3 -mt -fsimple=1
-ftrap=%none
  -nofstore -xbuiltin=%all -xlibmil -xlibmopt
-xtarget=generic

I suppose it would be better if all the places in
distutils which log
compiler commands without extra args escaped their %
signs.  This
seems like an acceptable compromise though.

Skip


----------------------------------------------------------------------

Comment By: splitscreen (splitscreen)
Date: 2006-03-27 21:27

Message:
Logged In: YES 
user_id=1126061

I can't reproduce on 2.4.2. Although maybe I misunderstood...

Are you saying that _log() barfs when you pass an empty tuple?

Passing an empty tuple to _log() works fine here..

I can understand it breaking when you pass some format
string to args and the msg contains an '%', that's the
developer's fault for not escaping the precentage sign.

Could you clarify? Or am I totally wrong?

Thanks

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1458017&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to