Antoine Pitrou wrote:
> Le samedi 23 janvier 2010 à 20:43 +0100, M.-A. Lemburg a écrit :
>>
>> Now, we cannot easily remove this guessing since we're in stable
>> mode again with 3.1. Perhaps we should add a way to at least be
>> able to switch off this guessing, so that applications can be
>> tested in a predictable way, rather than depending on the test
>> runner's locale settings ?!
> 
> The simple way to switch off the guessing is to specify an encoding in
> open(). I don't know what other means of switching it off could be
> added.

I was thinking of a way to disable the automatic guessing, so that
bugs related to missing encoding specifications can more easily be
found.

One way of doing this would be to have a global
text_file_default_encoding which is set to "guess-encoding"
per default.

This global could then be set via a PYTHONTEXTFILEENCODING
OS variable or programmatically at runtime to define the
text file default encoding to use in open() if no explicit
encoding is specified.

To disable guessing, the variable would be set to "unknown"
(like you can do for the default encoding in Python 2.x to
disable automatic coercion of strings to Unicode).

Perhaps we could also add a warning to the open() API which warns
in case a file is opened in text mode without specifying an
encoding ?!

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 25 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        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

Reply via email to