mirror of
https://github.com/python/cpython.git
synced 2025-10-08 08:01:55 +00:00
Marc-Andre Lemburg <mal@lemburg.com>:
Made codecs.open() default to 'rb' as file mode.
This commit is contained in:
parent
d468bd3463
commit
349a3d3a9a
1 changed files with 6 additions and 1 deletions
|
@ -458,7 +458,7 @@ class StreamRecoder:
|
||||||
|
|
||||||
### Shortcuts
|
### Shortcuts
|
||||||
|
|
||||||
def open(filename, mode, encoding=None, errors='strict', buffering=1):
|
def open(filename, mode='rb', encoding=None, errors='strict', buffering=1):
|
||||||
|
|
||||||
""" Open an encoded file using the given mode and return
|
""" Open an encoded file using the given mode and return
|
||||||
a wrapped version providing transparent encoding/decoding.
|
a wrapped version providing transparent encoding/decoding.
|
||||||
|
@ -468,6 +468,11 @@ def open(filename, mode, encoding=None, errors='strict', buffering=1):
|
||||||
codecs. Output is also codec dependent and will usually by
|
codecs. Output is also codec dependent and will usually by
|
||||||
Unicode as well.
|
Unicode as well.
|
||||||
|
|
||||||
|
Files are always opened in binary mode, even if no binary mode
|
||||||
|
was specified. Thisis done to avoid data loss due to encodings
|
||||||
|
using 8-bit values. The default file mode is 'rb' meaning to
|
||||||
|
open the file in binary read mode.
|
||||||
|
|
||||||
encoding specifies the encoding which is to be used for the
|
encoding specifies the encoding which is to be used for the
|
||||||
the file.
|
the file.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue