homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lemburg
Recipients amaury.forgeotdarc, lemburg, shamilbi
Date 2009年11月04日.18:18:06
SpamBayes Score 2.0272672e-13
Marked as misclassified No
Message-id <4AF1C568.9000001@egenix.com>
In-reply-to <1257357729.23.0.910181654488.issue7262@psf.upfronthosting.co.za>
Content
Amaury Forgeot d'Arc wrote:
> 
> Amaury Forgeot d'Arc <amauryfa@gmail.com> added the comment:
> 
> The docs say::
> Files are always opened in binary mode, even if no binary mode was
> specified. This is done to avoid data loss due to encodings using
> 8-bit values. This means that no automatic conversion of '\n' is done
> on reading and writing.
> 
> But this does not match the code of codecs.open()::
> if encoding is not None and \
> 'b' not in mode:
> # Force opening of the file in binary mode
> mode = mode + 'b'
> 
> When the encoding is None, the file is opened in text mode.
> Marc-Andre, what do you think? is it a documentation bug instead?
Agreed, it's a documentation bug. If no encoding is specified,
codecs.open() works just like the standard open() (except for
the default value of mode, but that's documented).
The idea was to provide a drop-in replacement for open() - with
the added encoding parameter support.
Perhaps the default mode should have been 'r' to match the
regular open() - I guess it's too late to change that, though.
History
Date User Action Args
2009年11月04日 18:18:08lemburgsetrecipients: + lemburg, amaury.forgeotdarc, shamilbi
2009年11月04日 18:18:06lemburglinkissue7262 messages
2009年11月04日 18:18:06lemburgcreate

AltStyle によって変換されたページ (->オリジナル) /