Fix return value from guess_mimetype on Python 3.

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

david
Review Board
release-4.0.x
reviewboard

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.

Summary
Fix return value from guess_mimetype on Python 3.
chipx86
  1. Ship It!
  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (c5cbeac)
bnie
  1. 
      
  2. 
      
Loading...