Commits

Anonymous committed 0b5cb97

Fix opening binary files under Py3k (thanks to Dominic Fitzpatrick).

  • Participants
  • Parent commits 77fe213

Comments (0)

Files changed (2)

File docutils/HISTORY.txt

   - FileInput/FileOutput: no system-exit on IOError.  The `handle_io_errors`
     option is ignored and will be removed in a future release.
   - Fix Py3k error writing to stdout with encoding differing from default.
+  - Fix opening binary files under Py3k (thanks to Dominic Fitzpatrick).
 
 * docutils/parsers/rst/directives/misc.py
 

File docutils/docutils/io.py

 
     mode = 'w'
     """The mode argument for `open()`."""
-    # 'wb' for binary (e.g. OpenOffice) files.
+    # 'wb' for binary (e.g. OpenOffice) files (see also `BinaryFileOutput`).
     # (Do not use binary mode ('wb') for text files, as this prevents the
     # conversion of newlines to the system specific default.)
 
 
     def open(self):
         # Specify encoding in Python 3.
-        if sys.version_info >= (3,0):
+        if sys.version_info >= (3,0) and 'b' not in self.mode:
             kwargs = {'encoding': self.encoding,
                       'errors': self.error_handler}
         else: