-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 M.-A. Lemburg wrote: > 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).
If it isn't disabled by default, then the people this bites won't ever know what is happening: they will stay happily ignorant until the guessed encoding silently correpts their data. > 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 ?! That ounds like a good plan to me, given that backward-compatibility requires keeping the guessing enabled by default. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAktd4/oACgkQ+gerLs4ltQ4ZEQCeOMqOvJBuyNIqY/gOKQN0thbN NoYAoJdctHukxA4nVvRCcmev9EFCcmBF =4vN0 -----END PGP SIGNATURE----- _______________________________________________ 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