4958: Diff error bundle uses wrong string type on Python 3 (bytes vs. unicode)


What version are you running?


What's the URL of the page containing the problem?

Diff error bundle.

What steps will reproduce the problem?

  1. Have a review request with a patch that cannot be applied.
  2. Attempt to download the error bundle.

What is the expected output? What do you see instead?

Bundle view results in this error:

Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/views.py", line 849, in get
    zipfile.writestr('%s.orig' % basename, patch_error.orig_file)
  File "/usr/lib/python3.8/zipfile.py", line 1816, in writestr
    with self.open(zinfo, mode='w') as dest:
  File "/usr/lib/python3.8/zipfile.py", line 1517, in open
    return self._open_to_write(zinfo, force_zip64=force_zip64)
  File "/usr/lib/python3.8/zipfile.py", line 1614, in _open_to_write
TypeError: string argument expected, got 'bytes'

Looks like we need to open the ZipFile as binary instead of text. This only occurs on Python 3 due to Python 2's wishy-washiness with string types.

#1 david
  • +Component:DiffViewer
#2 kylemclean

I'll try to fix this one.

#3 david

This was fixed in 4.0.10

  • -New