def _magic_get_file_type(f, _):
    file_type = magic.from_buffer(f.read(1024), mime=True)
    f.seek(0)
    return file_type.decode('utf-8')


def _guess_file_type(_, filename):
    return mimetypes.guess_type(filename)[0]


try:
    import magic
except ImportError:
    import mimetypes
    get_file_type = _guess_file_type
else:
    get_file_type = _magic_get_file_type

@@ -113,32 +113,30 @@
 urn 
-file_type.decode('utf-8'
+maybe_decode(file_type
 )%0A%0A%0A
@@ -170,16 +170,16 @@
 ename):%0A
-
     retu
@@ -217,16 +217,228 @@
 e)%5B0%5D%0A%0A%0A
+# return str on python3.  Don't want to unconditionally%0A# decode because that results in unicode on python2%0Adef maybe_decode(s):%0A    if str == bytes:%0A        return s%0A    else:%0A        return s.decode('utf-8')%0A%0A%0A
 try:%0A   

Return str rather than bytes for the description strings on python3.