This is an archive of the discontinued Mercurial Phabricator instance.

py3: pass str and return bytes from mimetypes.guess_type()
ClosedPublic

Authored by indygreg on Oct 12 2018, 4:09 AM.

Details

Summary

This function wants a str (which represents a path) and returns a str.
We normalize input to str and output to bytes.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Oct 12 2018, 4:09 AM
This revision was automatically updated to reflect the committed changes.
yuja added a subscriber: yuja.Oct 12 2018, 11:08 AM

+ mt = pycompat.sysbytes(
+ mimetypes.guess_type(pycompat.fsdecode(f))[0]
+ or 'application/octet-stream')

The default value has to be either r'' prefixed or moved out of the
sysbytes().