UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 (invalid continuation byte)

Bug #1791274 reported by Emmanuel Fleury on 2018-09-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Rubber
Undecided
Unassigned

Bug Description

I recently ran into an encoding bug in the Python code. Basically, rubber stop the build of the LaTeX file into PDF, and displays:

    Traceback (most recent call last):
  File "/usr/bin/rubber", line 17, in <module>
    sys.exit (cmdline (args))
  File "/usr/lib/python3/dist-packages/rubber/cmdline.py", line 432, in __call__
    self.main (cmdline)
  File "/usr/lib/python3/dist-packages/rubber/cmdline.py", line 373, in main
    self.process_source (env)
  File "/usr/lib/python3/dist-packages/rubber/cmdline.py", line 460, in process_source
    self.build (env)
  File "/usr/lib/python3/dist-packages/rubber/cmdline.py", line 401, in build
    ret = env.final.make(self.force)
  File "/usr/lib/python3/dist-packages/rubber/depend.py", line 143, in make
    rv = self.real_make (force)
  File "/usr/lib/python3/dist-packages/rubber/depend.py", line 184, in real_make
    if not self.run ():
  File "/usr/lib/python3/dist-packages/rubber/converters/latex.py", line 1313, in run
    if not self.compile():
  File "/usr/lib/python3/dist-packages/rubber/converters/latex.py", line 1232, in compile
    if not self.parse_log ():
  File "/usr/lib/python3/dist-packages/rubber/converters/latex.py", line 1246, in parse_log
    return self.log.readlog (logfile_name, logfile_limit)
  File "/usr/lib/python3/dist-packages/rubber/converters/latex.py", line 189, in readlog
    whole_file = fp.read (limit)
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 34129: invalid continuation byte

I looked a bit to search the origin of the problem (thanks to the stack trace), and I suggest to change the line 183 of /usr/lib/python3/dist-packages/rubber/converters/latex.py as follow:

      self.lines = None
  try:
- with open (name, encoding='utf-8') as fp:
+ with open (name, encoding='utf-8', errors='replace') as fp:
    line = fp.readline ()

After changing this line, it worked like a charm with my files.

Thanks for reporting.
Release 1.5.1 hopefully fixes this issue.

Sebastian Kapfer (caci) on 2018-10-17
Changed in rubber:
status: New → Fix Released
milestone: none → 2.0
milestone: 2.0 → none
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers