summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2000-06-21 21:21:04 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2000-06-21 21:21:04 (GMT)
commit349a3d3a9a4a25a217e2060bcecc10177fa549da (patch)
tree73f5aea4b40cc2aa5cb72032e1991e98f0c6a245 /Lib
parentd468bd3463085b1544a8f09981dc81fd615d2da7 (diff)
downloadcpython-349a3d3a9a4a25a217e2060bcecc10177fa549da.zip
cpython-349a3d3a9a4a25a217e2060bcecc10177fa549da.tar.gz
cpython-349a3d3a9a4a25a217e2060bcecc10177fa549da.tar.bz2
Marc-Andre Lemburg <mal@lemburg.com>:
Made codecs.open() default to 'rb' as file mode.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/codecs.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/codecs.py b/Lib/codecs.py
index 1a71fab..fbb9824 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -458,7 +458,7 @@ class StreamRecoder:
### 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
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
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
the file.