comparison mercurial/statichttprepo.py @ 46202:5135b393884b

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
author Joerg Sonnenberger <joerg@bec.de>
date Mon, 28 Dec 2020 01:21:58 +0100
parents 5523e3e1bc71
children bc2519513ae0
comparison
equal deleted inserted replaced
46201:b986e3342827 46202:5135b393884b
59 f = self.opener.open(req) 59 f = self.opener.open(req)
60 data = f.read() 60 data = f.read()
61 code = f.code 61 code = f.code
62 except urlerr.httperror as inst: 62 except urlerr.httperror as inst:
63 num = inst.code == 404 and errno.ENOENT or None 63 num = inst.code == 404 and errno.ENOENT or None
64 raise IOError(num, inst) 64 # Explicitly convert the exception to str as Py3 will try
65 # convert it to local encoding and with as the HTTPResponse
66 # instance doesn't support encode.
67 raise IOError(num, str(inst))
65 except urlerr.urlerror as inst: 68 except urlerr.urlerror as inst:
66 raise IOError(None, inst.reason) 69 raise IOError(None, inst.reason)
67 70
68 if code == 200: 71 if code == 200:
69 # HTTPRangeHandler does nothing if remote does not support 72 # HTTPRangeHandler does nothing if remote does not support