diff mercurial/hgweb/common.py @ 40158:9310037f0636

py3: pass str and return bytes from mimetypes.guess_type() This function wants a str (which represents a path) and returns a str. We normalize input to str and output to bytes. Differential Revision: https://phab.mercurial-scm.org/D4967
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 11 Oct 2018 21:47:39 +0200
parents a1110db1e455
children d216ae4cc3f6
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Thu Oct 11 22:27:52 2018 +0200
+++ b/mercurial/hgweb/common.py	Thu Oct 11 21:47:39 2018 +0200
@@ -182,7 +182,8 @@
             break
     try:
         os.stat(path)
-        ct = mimetypes.guess_type(pycompat.fsdecode(path))[0] or "text/plain"
+        ct = pycompat.sysbytes(
+            mimetypes.guess_type(pycompat.fsdecode(path))[0] or "text/plain")
         with open(path, 'rb') as fh:
             data = fh.read()