# HG changeset patch # User Joerg Sonnenberger # Date 2020-12-28 00:21:58 # Node ID 5135b393884b0a545e4fb59df7988486ebc2d172 # Parent b986e3342827e7b9419c5df2f67e4ebd96e35ccb 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 diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -61,7 +61,10 @@ class httprangereader(object): 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)