[Python-Dev] PEP 263 - default encoding (original) (raw)

M.-A. Lemburg mal@lemburg.com
Fri, 15 Mar 2002 18:09:16 +0100


Guido van Rossum wrote:

> My conclusion to all this is to withdraw the default encoding > idea and replace it with the fixed ASCII default. This default > won't be changeable by other means that adding an explicit header > to the source file. +1.

I have reworded the phase 1 implementation as follows:

1. Implement the magic comment detection, but only apply the
   detected encoding to Unicode literals in the source file.

   If no magic comment is used, Python should continue to
   use the standard [raw-]unicode-escape codecs for Unicode
   literals.

   In addition to this step and to aid in the transition to
   explicit encoding declaration, the tokenizer must check the
   complete source file for compliance with the declared
   encoding. If the source file does not properly decode, a single
   warning is generated per file.

Note the second paragraph. This is needed to have non-ASCII Unicode literals generate a warning but not a UnicodeError in phase 1.

Phase 2 will then raise errors for any non-ASCII character in source files which do not specify the encoding.

I guess the PEP is ready for BDFL pronouncement now.

-- Marc-Andre Lemburg CEO eGenix.com Software GmbH


Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/