[Python-Dev] open(): set the default encoding to 'utf-8' in Python 3.3?

Victor Stinner victor.stinner at haypocalc.com
Wed Jun 29 12:01:28 CEST 2011

Le mercredi 29 juin 2011 à 09:21 +0200, Baptiste Carvello a écrit :
> By the way, I just thought that for real programming, I would love to have a 
> -Wcrossplatform command switch, which would warn for all unportable constructs 
> in one go. That way, I don't have to remember which parts of 'os' wrap 
> posix-only functionnality.

When I developed using PHP, error_reporting(E_ALL) was really useful. I
would like a same function on Python, but I realized that it is not
necessary. Python is already strict *by default*.

Python can help developers to warn them about some "corner cases". We
have already the -bb option for bytes/str warnings (in Python 3),
-Werror to convert warnings to exceptions, and ResourceWarning (since
Python 3.2) for unclosed files/sockets. I "just" would like a new
warning for an implicit locale encoding, so -Wcrossplatform would be as
easy as -Werror. -Werror is like Perl "use strict;" or PHP
error_reporting(E_ALL). Use -Wd if you prefer to display warnings
instead of raising exceptions.

See issue #11455 and #11470 for a new "CompatibilityWarning", it's not
"cross platform" but "cross Python" :-) It warns about implementation
details like non strings keys in a type dict.


More information about the Python-Dev mailing list