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


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

def _magic_get_file_type(f, _):
    file_type = magic.from_buffer(f.read(1024), mime=True)
    f.seek(0)
    return file_type.decode("ASCII")


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

Fix libmagic issue with Python 3
Fix libmagic issue with Python 3

  def _magic_get_file_type(f, _):
      file_type = magic.from_buffer(f.read(1024), mime=True)
      f.seek(0)
-     return file_type
+     return file_type.decode("ASCII")
  
  
  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
  
Fix libmagic issue with Python 3
## Code Before:
def _magic_get_file_type(f, _):
    file_type = magic.from_buffer(f.read(1024), mime=True)
    f.seek(0)
    return file_type


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

## Instruction:
Fix libmagic issue with Python 3
## Code After:
def _magic_get_file_type(f, _):
    file_type = magic.from_buffer(f.read(1024), mime=True)
    f.seek(0)
    return file_type.decode("ASCII")


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
