On 2008-12-08 19:26, Guido van Rossum wrote: > On Sun, Dec 7, 2008 at 3:53 PM, Terry Reedy <[EMAIL PROTECTED]> wrote: >> Here is a possible use case: I want filenames as 3.0 strings and I >> anticipate no problems at present but, as you say above, something might >> happen years in the future. I am using 3.0 *because* of the strings == >> unicode feature. I would like to write >> >> try: >> files = os.listdir(somedir, errors = strict) >> except OSError as e: >> log(<verbose error message that includes somedir and e>) >> files = os.listdir(somedir) >> >> and go one without the problem file but not without logging the problem so a >> future maintainer can consider what to do about it, but only when there is >> an actual need to think about it.
If that error parameter is the same as in unicode(value, errors), then this would be a useful feature: People could then choose among the already existing error handlers ('strict', 'ignore', 'replace', 'xmlcharrefreplace') or register their own ones via the codecs module. Such application specific error handlers could then also apply whatever fancy round-trip safe encoding of non-decodable bytes to Unicode escapes, private code points, etc. as seen fit by the application. Perhaps we should also add an ''encoding'' parameter that can be set on a per directory basis (if necessary) and defaults to the global file system encoding. If an application hits directory that is known to cause problems, it could then chose to receive the file names in a different, more suitable encoding. This allows implementing fallback mechanisms with a list of common encodings for a locale. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Dec 08 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2008-12-02: Released mxODBC.Connect 1.0.0 http://python.egenix.com/ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com