Menu

#282 rst2odt fails on python3: AttributeError: 'str' object has no attribute 'decode'

closed-fixed
nobody
ODT Writer (17)
5
2020-03-03
2015-08-11
No

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'

Related

Bugs: #282

Discussion

  • Matthijs Kooijman

    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.

     
  • Günter Milde

    Günter Milde - 2017-06-28
    • labels: --> ODT Writer
     
    • Dave Kuhlman

      Dave Kuhlman - 2017-07-03

      Fixed.

      Dave K

      On Wed, Jun 28, 2017 at 10:34:38PM +0000, "Günter Milde" via Docutils-develop wrote:

      • 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

      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-develop@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.


      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-develop@lists.sourceforge.net
      https://lists.sourceforge.net/lists/listinfo/docutils-develop

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

      --

      Dave Kuhlman
      http://www.davekuhlman.org

       

      Related

      Bugs: #282

  • Günter Milde

    Günter Milde - 2017-07-17
    • status: open --> closed-fixed
     
  • Günter Milde

    Günter Milde - 2017-07-17

    Closing. Thanks for the fix.

     

Log in to post a comment.