Discussion:
[Docutils-users] Traceback output
Konstas Marmatakis
2014-05-23 11:29:48 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hallo,
I tried to use sphinx rst2html to convert rst file to html.

The command was:
C:\python33\Scripts\rst2html.py INSTALL.rst
OS: Windows 7 64bit (Greek)
Python: version 3.3.3

The traceback output is:

Traceback (most recent call last):
File "C:\python33\Scripts\rst2html.py", line 5, in <module>
pkg_resources.run_script('docutils==0.10', 'rst2html.py')
File
"C:\Python33\lib\site-packages\distribute-0.6.30-py3.3.egg\pkg_resources.py",
line 499, in run_
script
self.require(requires)[0].run_script(script_name, ns)
File
"C:\Python33\lib\site-packages\distribute-0.6.30-py3.3.egg\pkg_resources.py",
line 1240, in run
_script
exec(compile(open(script_filename).read(), script_filename, 'exec'),
namespace, namespace)
File
"c:\python33\lib\site-packages\docutils-0.10-py3.3.egg\EGG-INFO\scripts\rst2html.py",
line 23,
in <module>
publish_cmdline(writer_name='html', description=description)
File
"C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\core.py", line
352, in publish_
cmdline
config_section=config_section, enable_exit_status=enable_exit_status)
File
"C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\core.py", line
219, in publish
output = self.writer.write(self.document, self.destination)
File
"C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\writers\__init__.py",
line 81,
in write
output = self.destination.write(self.output)
File
"C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\io.py",
line 374, in write
data = data.replace('\n', os.linesep) # fix endings
TypeError: expected bytes, bytearray or buffer compatible object


Thank you
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlN/MScACgkQsJq+5X4tTywgTgCeNpGcP1n3LNGvE3/kYtLfZJFc
jnsAniPLBa+olwHIu4FmT9+qm16lGsui
=8ZrK
-----END PGP SIGNATURE-----


---
Αυτό το email είναι απαλλαγμένο από ιούς και κακόβουλο λογισμικό, επειδή είναι ενεργή η προστασία avast! Antivirus.
http://www.avast.com
Guenter Milde
2014-05-26 11:42:30 UTC
Permalink
Dear Konstas,

sorry for the problems, thank you for reporting them.
Post by Konstas Marmatakis
I tried to use sphinx rst2html to convert rst file to html.
C:\python33\Scripts\rst2html.py INSTALL.rst
OS: Windows 7 64bit (Greek)
Python: version 3.3.3
Then you actually did not use Sphinx but (pur) Docutils. This means you are
at the right list.

It looks like you found one of the never-ending encoding problems aggravated
by the Python 2-3 divide.

In Python 2, most methods would "do the right thing" regarding unicode<->bytes
conversiond. However, in 3.3.:

The methods on bytes and bytearray objects don’t accept strings as
their arguments, just as the methods on strings don’t accept bytes as
their arguments.

-- https://docs.python.org/3.3/library/stdtypes.html#bytes-methods


Does the following patch help?

Günter

Index: io.py
===================================================================
--- io.py (Revision 7743)
+++ io.py (Arbeitskopie)
@@ -369,9 +369,9 @@
if ('b' not in self.mode and sys.version_info < (3,0)
or check_encoding(self.destination, self.encoding) is False
):
+ data = self.encode(data)
if sys.version_info >= (3,0) and os.linesep != '\n':
- data = data.replace('\n', os.linesep) # fix endings
- data = self.encode(data)
+ data = data.replace(b('\n'), b(os.linesep)) # fix endings

try: # In Python < 2.5, try...except has to be nested in try...finally.
try:

Loading...