On Sun, Jun 1, 2008 at 6:33 AM, Adam Olsen <[EMAIL PROTECTED]> wrote:
> I think the reason why strict/backslashreplace (respectively) work > well is that you can print a unicode string to stdout, have it fail > (encoding can't handle it), then get an exception printed to stderr > with the string escaped. > > Making stderr stricter would make it unable to print the string and > making stdout less strict would let the error pass silently (printing > potential garbage instead). > I agree these points. I know my preference was already denied by important persons in the python developers :), so may be I'm wrong. The release date is approaching fast. As Marc-Andre pointed out, the default error handler for sys.stdout may be out of scope. So I'm going to shut up and see whether community starts mumbling or not. But if you have spare time and interested, following is my points. I may be come back for Python 3.1 or 3.2 :). ====== How many scripts want to care about encoding error? If you ship your scripts with 'strict' error handler, users of the script should determine a certain encoding of output and should be responsible to set up correct runtime environment, which are not always possible. For example, we can not guarantee this trivial script would work on Windows: for filename in os.listdir("."): print(filename) The 'filename' can contain ASCII, Greek, Chinese or any other characters, so no encoding other than utf-8 (the only sane encoding for Unicode applications) may raise exceptions. In practice, the best thing we can do is printing escaped string silently and close can of worms:). Raising exceptions would be desired in some case, but for such cases, input data and environment should be examined by script, *before* the data are printed. Printing curt UnicodeEncodingError() message may not be what you want to your scripts. Thus, current restriction is too defensive for most of use-cases, IMO. As I wrote before, other languages I familiar(Java, .Net languages, Perl) don't raise exceptions by default, but silently print converted characters. Ditto for utilities such as 'ls'. _______________________________________________ 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