diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -183,7 +183,6 @@ from __future__ import absolute_import -import binascii import errno import os @@ -426,7 +425,7 @@ rulehash = rule.strip().split(' ', 1)[0] try: rev = node.bin(rulehash) - except (TypeError, binascii.Error): + except TypeError: raise error.ParseError("invalid changeset %s" % rulehash) return cls(state, rev) diff --git a/mercurial/node.py b/mercurial/node.py --- a/mercurial/node.py +++ b/mercurial/node.py @@ -11,7 +11,14 @@ # This ugly style has a noticeable effect in manifest parsing hex = binascii.hexlify -bin = binascii.unhexlify +# Adapt to Python 3 API changes. If this ends up showing up in +# profiles, we can use this version only on Python 3, and forward +# binascii.unhexlify like we used to on Python 2. +def bin(s): + try: + return binascii.unhexlify(s) + except binascii.Error as e: + raise TypeError(e) nullrev = -1 nullid = b"\0" * 20