changeset 40211:d216ae4cc3f6

py3: r'' prefix default values for mimetypes.guess_mime() As suggested by @yuja in D4967. Differential Revision: https://phab.mercurial-scm.org/D5020
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 12 Oct 2018 19:49:02 +0200
parents 8f192f2c4a1e
children 885d5cf9b6a4
files mercurial/hgweb/common.py mercurial/hgweb/webcommands.py
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Fri Oct 12 20:03:29 2018 +0000
+++ b/mercurial/hgweb/common.py	Fri Oct 12 19:49:02 2018 +0200
@@ -183,7 +183,7 @@
     try:
         os.stat(path)
         ct = pycompat.sysbytes(
-            mimetypes.guess_type(pycompat.fsdecode(path))[0] or "text/plain")
+            mimetypes.guess_type(pycompat.fsdecode(path))[0] or r"text/plain")
         with open(path, 'rb') as fh:
             data = fh.read()
 
--- a/mercurial/hgweb/webcommands.py	Fri Oct 12 20:03:29 2018 +0000
+++ b/mercurial/hgweb/webcommands.py	Fri Oct 12 19:49:02 2018 +0200
@@ -151,7 +151,7 @@
     if stringutil.binary(text):
         mt = pycompat.sysbytes(
             mimetypes.guess_type(pycompat.fsdecode(f))[0]
-            or 'application/octet-stream')
+            or r'application/octet-stream')
         text = '(binary:%s)' % mt
 
     def lines(context):
@@ -864,7 +864,7 @@
         if f.isbinary():
             mt = pycompat.sysbytes(
                 mimetypes.guess_type(pycompat.fsdecode(f.path()))[0]
-                or 'application/octet-stream')
+                or r'application/octet-stream')
             return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))]
         return f.data().splitlines()
 
@@ -952,7 +952,7 @@
         if fctx.isbinary():
             mt = pycompat.sysbytes(
                 mimetypes.guess_type(pycompat.fsdecode(fctx.path()))[0]
-                or 'application/octet-stream')
+                or r'application/octet-stream')
             lines = [dagop.annotateline(fctx=fctx.filectx(fctx.filerev()),
                                         lineno=1, text='(binary:%s)' % mt)]
         else: