ros-infrastructure / rosdoc_lite

A light-weight version of rosdoc that does not rely on ROS infrastructure for crawling packages.
10 stars 31 forks source link

[Bugfix] Fix decoding on python 3 #109

Closed yurirocha15 closed 7 months ago

yurirocha15 commented 7 months ago

When testing the changes in #108 using python3, I encountered the following error:

ERROR: Doxygen of package [] failed: write() argument must be str, not bytes
Traceback (most recent call last):
  File "<string>", line 194, in generate_docs
  File "rosdoc_lite/src/rosdoc_lite/doxygenator.py", line 263, in generate_doxygen
    doxy = package_doxygen_template(doxy_template, rd_config, path, package, html_dir, header_file.name, footer_file.name, manifest_dir, tagfile_dir, output_subfolder)
  File "rosdoc_lite/src/rosdoc_lite/doxygenator.py", line 186, in package_doxygen_template
    tagfiles = prepare_tagfiles(rd_config['tagfile_spec'], tagfile_dir, output_subfolder)
  File "rosdoc_lite/src/rosdoc_lite/doxygenator.py", line 140, in prepare_tagfiles
    tagfile.write(ret.read())
TypeError: write() argument must be str, not bytes

I believe I could not catch this on #108 unit tests because I was using a mock file, which seems not to raise any errors on write.

To fix this issue, I added a string decode logic before saving it to the file. As python2 does not have bytes I left the python 2 version as is.

@tfoote Sorry for not validating this before #108 was merged.