py3: remove use of str() in hgwebdir
authorYuya Nishihara <yuya@tcha.org>
Wed, 27 Sep 2017 19:04:32 +0900
changeset 34358 8cbcee0b923d
parent 34357 c41444a39de2
child 34359 ee10eb665036
py3: remove use of str() in hgwebdir '%d' can't be used here since port may be either integer or byte string.
mercurial/hgweb/hgwebdir_mod.py
tests/test-doctest.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Wed Sep 27 18:07:48 2017 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Wed Sep 27 19:04:32 2017 +0900
@@ -34,6 +34,7 @@
     error,
     hg,
     profiling,
+    pycompat,
     scmutil,
     templater,
     ui as uimod,
@@ -106,7 +107,7 @@
     if not path.startswith('/'):
         path = '/' + path
 
-    return name, str(port), path
+    return name, pycompat.bytestr(port), path
 
 class hgwebdir(object):
     """HTTP server for multiple repositories.
@@ -293,7 +294,7 @@
                         msg = encoding.strtolocal(inst.strerror)
                         raise ErrorResponse(HTTP_SERVER_ERROR, msg)
                     except error.RepoError as inst:
-                        raise ErrorResponse(HTTP_SERVER_ERROR, str(inst))
+                        raise ErrorResponse(HTTP_SERVER_ERROR, bytes(inst))
 
             # browse subdirectories
             subdir = virtual + '/'
--- a/tests/test-doctest.py	Wed Sep 27 18:07:48 2017 -0700
+++ b/tests/test-doctest.py	Wed Sep 27 19:04:32 2017 +0900
@@ -53,7 +53,7 @@
 testmod('mercurial.encoding')
 testmod('mercurial.formatter')
 testmod('mercurial.hg')
-testmod('mercurial.hgweb.hgwebdir_mod', py3=False)  # py3: repr(bytes) ?
+testmod('mercurial.hgweb.hgwebdir_mod')
 testmod('mercurial.match')
 testmod('mercurial.mdiff')
 testmod('mercurial.minirst')