statichttprepo: explicitly convert error message to str (issue6247)
authorJoerg Sonnenberger <joerg@bec.de>
Mon, 28 Dec 2020 01:21:58 +0100
changeset 46202 5135b393884b
parent 46201 b986e3342827
child 46203 63f0e31af0e5
statichttprepo: explicitly convert error message to str (issue6247) For Python 2.7, the implicit conversion of the HTTPError instance to str was good enough. For Python 3.x, this fails later when hitting the str to bytes conversion logic. Differential Revision: https://phab.mercurial-scm.org/D9661
mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py	Mon Dec 07 22:27:43 2020 +0100
+++ b/mercurial/statichttprepo.py	Mon Dec 28 01:21:58 2020 +0100
@@ -61,7 +61,10 @@
             code = f.code
         except urlerr.httperror as inst:
             num = inst.code == 404 and errno.ENOENT or None
-            raise IOError(num, inst)
+            # Explicitly convert the exception to str as Py3 will try
+            # convert it to local encoding and with as the HTTPResponse
+            # instance doesn't support encode.
+            raise IOError(num, str(inst))
         except urlerr.urlerror as inst:
             raise IOError(None, inst.reason)