On Wed, Apr 16, 2008 at 10:20 PM, Greg Ewing
<[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
>  > I disagree: I always recommend using %r to display (in an error
>  > message, log entry, etc), a string that may be in error,
>
>  For debugging messages, yes, but not output produced
>  in the normal course of operation. And "File Not Found"
>  I consider to be in the latter category -- the user
>  typed in the wrong file name, but it's still a string,
>  and should be displayed to him as such.

I respectfully disagree. Control characters and such in the string
should *definitely* be escaped. Regarding printable characters outside
the ASCII range, see my post in another thread (which somehow nearly
everybody appears to have missed); in Py3k I propose to pass printable
Unicode characters unchanged through repr(). stdout/stderr will set
their error attribute to backslashreplace so that if their encoding is
ASCII or some such, out-of-range characters will be printed as \uxxxx
rather than raising an exception during printing. But as I said,
please follow up to my other post.

Another reason to use %r is that if someone manages to include \n in a
filename, with %s the log message might be spread across two lines,
possibly confusing log parsers and even providing ways to hide illegal
activities from log scanners.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to