Discussion:
[Docutils-develop] [docutils:bugs] #282 rst2odt fails on python3:
Matthijs Kooijman
2015-08-11 11:18:50 UTC
Permalink
---

** [bugs:#282] rst2odt fails on python3: AttributeError: 'str' object has no attribute 'decode'**

**Status:** open
**Group:** Default
**Created:** Tue Aug 11, 2015 11:18 AM UTC by Matthijs Kooijman
**Last Updated:** Tue Aug 11, 2015 11:18 AM UTC
**Owner:** nobody


This exception occurs because apparently `ConfigParser` already decodes the strings it returns somehow. Tested on a Debian Jessie system, using 3.4.2. To reproduce:

$ touch test.rst
$ echo -e '[Formats]\nfoo=bar' > test.ini
$ python3 /usr/share/docutils/scripts/python3/rst2odt --traceback --odf-config-file=test.ini test.rst test.odt
test.rst:: (WARNING/2) Style "foo" is not a style used by odtwriter.
Traceback (most recent call last):
File "/usr/share/docutils/scripts/python3/rst2odt", line 29, in <module>
description=description)
File "/usr/lib/python3/dist-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/dist-packages/docutils/core.py", line 219, in publish
output = self.writer.write(self.document, self.destination)
File "/usr/lib/python3/dist-packages/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/usr/lib/python3/dist-packages/docutils/writers/odf_odt/__init__.py", line 550, in translate
self.visitor = self.translator_class(self.document)
File "/usr/lib/python3/dist-packages/docutils/writers/odf_odt/__init__.py", line 807, in __init__
self.format_map[rststyle] = format.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Matthijs Kooijman
2015-08-11 11:19:47 UTC
Permalink
This was using docutils 0.12, but a quick look at the relevant file in trunk shows the decode still happens, so I suspect this is still broken with trunk.



---

** [bugs:#282] rst2odt fails on python3: AttributeError: 'str' object has no attribute 'decode'**

**Status:** open
**Group:** Default
**Created:** Tue Aug 11, 2015 11:18 AM UTC by Matthijs Kooijman
**Last Updated:** Tue Aug 11, 2015 11:18 AM UTC
**Owner:** nobody


This exception occurs because apparently `ConfigParser` already decodes the strings it returns somehow. Tested on a Debian Jessie system, using 3.4.2. To reproduce:

$ touch test.rst
$ echo -e '[Formats]\nfoo=bar' > test.ini
$ python3 /usr/share/docutils/scripts/python3/rst2odt --traceback --odf-config-file=test.ini test.rst test.odt
test.rst:: (WARNING/2) Style "foo" is not a style used by odtwriter.
Traceback (most recent call last):
File "/usr/share/docutils/scripts/python3/rst2odt", line 29, in <module>
description=description)
File "/usr/lib/python3/dist-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/dist-packages/docutils/core.py", line 219, in publish
output = self.writer.write(self.document, self.destination)
File "/usr/lib/python3/dist-packages/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/usr/lib/python3/dist-packages/docutils/writers/odf_odt/__init__.py", line 550, in translate
self.visitor = self.translator_class(self.document)
File "/usr/lib/python3/dist-packages/docutils/writers/odf_odt/__init__.py", line 807, in __init__
self.format_map[rststyle] = format.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Dave Kuhlman
2017-07-03 22:20:49 UTC
Permalink
Fixed.

Dave K
- **labels**: --> ODT Writer
---
** [bugs:#282] rst2odt fails on python3: AttributeError: 'str' object has no attribute 'decode'**
**Status:** open
**Group:** Default
**Labels:** ODT Writer
**Created:** Tue Aug 11, 2015 11:18 AM UTC by Matthijs Kooijman
**Last Updated:** Tue Aug 11, 2015 11:19 AM UTC
**Owner:** nobody
$ touch test.rst
$ echo -e '[Formats]\nfoo=bar' > test.ini
$ python3 /usr/share/docutils/scripts/python3/rst2odt --traceback --odf-config-file=test.ini test.rst test.odt
test.rst:: (WARNING/2) Style "foo" is not a style used by odtwriter.
File "/usr/share/docutils/scripts/python3/rst2odt", line 29, in <module>
description=description)
File "/usr/lib/python3/dist-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/dist-packages/docutils/core.py", line 219, in publish
output = self.writer.write(self.document, self.destination)
File "/usr/lib/python3/dist-packages/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/usr/lib/python3/dist-packages/docutils/writers/odf_odt/__init__.py", line 550, in translate
self.visitor = self.translator_class(self.document)
File "/usr/lib/python3/dist-packages/docutils/writers/odf_odt/__init__.py", line 807, in __init__
self.format_map[rststyle] = format.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'
---
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-develop mailing list
https://lists.sourceforge.net/lists/listinfo/docutils-develop
Please use "Reply All" to reply to the list.
--
Dave Kuhlman
http://www.davekuhlman.org

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-develop mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-develop

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