mercurial/node.py
changeset 36238 f574cc00831a
parent 32684 af854b1b36f8
child 37448 d7114f883505
--- a/mercurial/node.py	Fri Feb 16 11:30:18 2018 -0800
+++ b/mercurial/node.py	Wed Feb 14 21:34:12 2018 -0500
@@ -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