]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Marc-Andre Lemburg <mal@lemburg.com>:
authorMarc-André Lemburg <mal@egenix.com>
Wed, 21 Jun 2000 21:21:04 +0000 (21:21 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Wed, 21 Jun 2000 21:21:04 +0000 (21:21 +0000)
Made codecs.open() default to 'rb' as file mode.

Lib/codecs.py

index 1a71fab18658fd3fd6a885d9e8f73c21477ca4dd..fbb982455b6c4b2341974121c004d62fe7b4fb06 100644 (file)
@@ -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.