comparison mercurial/httppeer.py @ 36430:efebfa9b4cab

httppeer: explicitly catch urlerr.httperror and re-raise On Python 3 it seems urllib.error.HTTPError doesn't set the .args field of the exception to have any contents, which then breaks our socket.error catch. This works around that issue. Differential Revision: https://phab.mercurial-scm.org/D2448
author Augie Fackler <augie@google.com>
date Mon, 26 Feb 2018 00:50:35 -0500
parents 23d12524a202
children 5bc7ff103081
comparison
equal deleted inserted replaced
36429:f8ea6988a5fb 36430:efebfa9b4cab
437 r = self._call(cmd, data=fp, headers=headers, **args) 437 r = self._call(cmd, data=fp, headers=headers, **args)
438 vals = r.split('\n', 1) 438 vals = r.split('\n', 1)
439 if len(vals) < 2: 439 if len(vals) < 2:
440 raise error.ResponseError(_("unexpected response:"), r) 440 raise error.ResponseError(_("unexpected response:"), r)
441 return vals 441 return vals
442 except urlerr.httperror:
443 # Catch and re-raise these so we don't try and treat them
444 # like generic socket errors. They lack any values in
445 # .args on Python 3 which breaks our socket.error block.
446 raise
442 except socket.error as err: 447 except socket.error as err:
443 if err.args[0] in (errno.ECONNRESET, errno.EPIPE): 448 if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
444 raise error.Abort(_('push failed: %s') % err.args[1]) 449 raise error.Abort(_('push failed: %s') % err.args[1])
445 raise error.Abort(err.args[1]) 450 raise error.Abort(err.args[1])
446 finally: 451 finally: