[Updated] D9318: errors: catch urllib errors specifically instead of using safehasattr()
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Tue Nov 17 06:10:15 UTC 2020
Closed by commit rHGae00e170f2d1: errors: catch urllib errors specifically instead of using safehasattr() (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9318?vs=23488&id=23519
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9318/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9318
AFFECTED FILES
mercurial/scmutil.py
CHANGE DETAILS
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -236,20 +236,20 @@
ui.error(_(b"(did you forget to compile extensions?)\n"))
elif m in b"zlib".split():
ui.error(_(b"(is your Python install correct?)\n"))
+ except util.urlerr.httperror as inst:
+ ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst))
+ except util.urlerr.urlerror as inst:
+ try: # usually it is in the form (errno, strerror)
+ reason = inst.reason.args[1]
+ except (AttributeError, IndexError):
+ # it might be anything, for example a string
+ reason = inst.reason
+ if isinstance(reason, pycompat.unicode):
+ # SSLError of Python 2.7.9 contains a unicode
+ reason = encoding.unitolocal(reason)
+ ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason))
except (IOError, OSError) as inst:
- if util.safehasattr(inst, b"code"): # HTTPError
- ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst))
- elif util.safehasattr(inst, b"reason"): # URLError or SSLError
- try: # usually it is in the form (errno, strerror)
- reason = inst.reason.args[1]
- except (AttributeError, IndexError):
- # it might be anything, for example a string
- reason = inst.reason
- if isinstance(reason, pycompat.unicode):
- # SSLError of Python 2.7.9 contains a unicode
- reason = encoding.unitolocal(reason)
- ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason))
- elif (
+ if (
util.safehasattr(inst, b"args")
and inst.args
and inst.args[0] == errno.EPIPE
To: martinvonz, #hg-reviewers, Alphare, mharbison72
Cc: mharbison72, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20201117/4010c263/attachment-0002.html>
More information about the Mercurial-patches
mailing list