Patchwork D2448: httppeer: explicitly catch urlerr.httperror and re-raise

login
register
mail settings
Submitter phabricator
Date Feb. 26, 2018, 6:02 a.m.
Message ID <differential-rev-PHID-DREV-w27k6ymlx6qyzc5mzfpj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28379/
State Superseded
Headers show

Comments

phabricator - Feb. 26, 2018, 6:02 a.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2448

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -439,6 +439,11 @@ 
             if len(vals) < 2:
                 raise error.ResponseError(_("unexpected response:"), r)
             return vals
+        except urlerr.httperror:
+            # Catch and re-raise these so we don't try and treat them
+            # like generic socket errors. They lack any values in
+            # .args on Python 3 which breaks our socket.error block.
+            raise
         except socket.error as err:
             if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
                 raise error.Abort(_('push failed: %s') % err.args[1])