Fix return value from guess_mimetype on Python 3.

Review Request #11186 — Created Sept. 19, 2020 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

Mimetype guessing was returning the mimetype as bytes rather than
str (unicode), due to the default behavior of subprocess.Popen. On
Python 2 this is fine because bytes and unicode are pretty freely
intercompatible, but on Python 3 this would then explode later on when
attempting to serialize a file attachment object with that mimetype set,
since parse_mimetype didn't understand bytes.

While I was here I fixed the order of arguments in a log message to make
more sense.

I had been experiencing problems when using certain Review Bot tools
with the Review Board server running on Python 3.8. When the tool
attempted to create the tool-output attachment, it would get an error
serializing "bytes" and spit out a warning about being unable to parse
the mimetype. After this change, everything works as expected.

Commits

Files