From: <mi...@us...> - 2012-11-06 13:49:37
|
Revision: 7536 http://docutils.svn.sourceforge.net/docutils/?rev=7536&view=rev Author: milde Date: 2012-11-06 13:49:27 +0000 (Tue, 06 Nov 2012) Log Message: ----------- Fix opening binary files under Py3k (thanks to Dominic Fitzpatrick). Modified Paths: -------------- trunk/docutils/HISTORY.txt trunk/docutils/docutils/io.py Modified: trunk/docutils/HISTORY.txt =================================================================== --- trunk/docutils/HISTORY.txt 2012-10-25 12:01:12 UTC (rev 7535) +++ trunk/docutils/HISTORY.txt 2012-11-06 13:49:27 UTC (rev 7536) @@ -33,6 +33,7 @@ - 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 Modified: trunk/docutils/docutils/io.py =================================================================== --- trunk/docutils/docutils/io.py 2012-10-25 12:01:12 UTC (rev 7535) +++ trunk/docutils/docutils/io.py 2012-11-06 13:49:27 UTC (rev 7536) @@ -297,7 +297,7 @@ 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.) @@ -346,7 +346,7 @@ 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: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |