On 21/01/2010 11:15, M.-A. Lemburg wrote:
Michael Foord wrote:
On 20/01/2010 21:37, M.-A. Lemburg wrote:
The only supported default encodings in Python are:

   Python 2.x: ASCII
   Python 3.x: UTF-8

Is this true? I thought the default encoding in Python 3 was platform
specific (i.e. cp1252 on Windows). That means files written using the
default encoding on one platform may not be read correctly on another
platform. Slightly off topic for this discussion I realise.
Yes, the above is what Python implements.

However, the default encoding is only used internally when converting
8-bit strings to Unicode.

Ok. I know when in Python 2 an implicit encode (or decode) can happen. When in Python 3 can implicit encodes happen?

When it comes to I/O there are several other encodings which can get
used, e.g. stdin/out/err streams each have their own encoding
(just like arbitrary file objects), OS APIs use their own encoding,
etc.

If no encoding is given for these, Python will try to find a
reasonable default. Python 2.x and 3.x differ a lot in how this
is done.

As always: It's better not to rely on such defaults and explicitly
provide the encoding as parameter where possible.

Sure. I do worry that developers will still rely on the default behavior assuming that Python 3 "fixes their encoding problems" and cause cross-platform issues. But oh well.

Michael

--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of 
your employer, to release me from all obligations and waivers arising from any 
and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, 
clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and 
acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your 
employer, its partners, licensors, agents and assigns, in perpetuity, without 
prejudice to my ongoing rights and privileges. You further represent that you 
have the authority to release me from any BOGUS AGREEMENTS on behalf of your 
employer.


_______________________________________________
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