Discussion:
[Docutils-users] rst2odt can't handle images in python 3: AttributeError: 'str' object has no attribute 'decode'
Jorge Scandaliaris
2015-02-11 07:54:12 UTC
Permalink
Hi,
I found an old reference for this problem in Debian's bug tracker [1], where
it was mentioned that a solution was introduced in 0.11-1. I have the same
problem on 0.12 and python 3.4. I have manually applied the changes that I
found in [2] and the problem is solved here. Is it possible that the fix was
applied by Debian and not upstream?


Jorge

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=714313
[2] http://sourceforge.net/p/docutils/patches/113/

Minimal example triggering the bug (copy/paste between ---, adapt to use an
existing image):
---------------------------------
####
Test
####

.. image:: images/test.png
----------------------------------

Result:

Traceback (most recent call last):
File "/usr/bin/rst2odt", line 29, in <module>
description=description)
File "/usr/lib/python3.4/site-packages/docutils/core.py", line 551, in
publish_cmdline_to_binary
config_section=config_section, enable_exit_status=enable_exit_status)
File "/usr/lib/python3.4/site-packages/docutils/core.py", line 219, in publish
output = self.writer.write(self.document, self.destination)
File "/usr/lib/python3.4/site-packages/docutils/writers/__init__.py", line
80, in write
self.translate()
File
"/usr/lib/python3.4/site-packages/docutils/writers/odf_odt/__init__.py",
line 554, in translate
self.assemble_my_parts()
File
"/usr/lib/python3.4/site-packages/docutils/writers/odf_odt/__init__.py",
line 573, in assemble_my_parts
self.store_embedded_files(zfile)
File
"/usr/lib/python3.4/site-packages/docutils/writers/odf_odt/__init__.py",
line 598, in store_embedded_files
destination1 = destination.decode('latin-1').encode('utf-8')
AttributeError: 'str' object has no attribute 'decode


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
engelbert gruber
2015-02-11 12:52:57 UTC
Permalink
that is a python3 problem not an encoding problem

i removed .decode('latin-1').encode('utf-8')

1. latin1 as input is an assumption
2. changing the name without the reference , might break things
3. decode/encode should happen in docutils.io (IMHO)

cheers
Post by Jorge Scandaliaris
Hi,
I found an old reference for this problem in Debian's bug tracker [1], where
it was mentioned that a solution was introduced in 0.11-1. I have the same
problem on 0.12 and python 3.4. I have manually applied the changes that I
found in [2] and the problem is solved here. Is it possible that the fix was
applied by Debian and not upstream?
Jorge
[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=714313
[2] http://sourceforge.net/p/docutils/patches/113/
Minimal example triggering the bug (copy/paste between ---, adapt to use an
---------------------------------
####
Test
####
.. image:: images/test.png
----------------------------------
File "/usr/bin/rst2odt", line 29, in <module>
description=description)
File "/usr/lib/python3.4/site-packages/docutils/core.py", line 551, in
publish_cmdline_to_binary
config_section=config_section, enable_exit_status=enable_exit_status)
File "/usr/lib/python3.4/site-packages/docutils/core.py", line 219, in publish
output = self.writer.write(self.document, self.destination)
File "/usr/lib/python3.4/site-packages/docutils/writers/__init__.py", line
80, in write
self.translate()
File
"/usr/lib/python3.4/site-packages/docutils/writers/odf_odt/__init__.py",
line 554, in translate
self.assemble_my_parts()
File
"/usr/lib/python3.4/site-packages/docutils/writers/odf_odt/__init__.py",
line 573, in assemble_my_parts
self.store_embedded_files(zfile)
File
"/usr/lib/python3.4/site-packages/docutils/writers/odf_odt/__init__.py",
line 598, in store_embedded_files
destination1 = destination.decode('latin-1').encode('utf-8')
AttributeError: 'str' object has no attribute 'decode
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Docutils-users mailing list
https://lists.sourceforge.net/lists/listinfo/docutils-users
Please use "Reply All" to reply to the list.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.

Loading...