# HG changeset patch # User Gregory Szorc # Date 2018-02-11 21:23:26 # Node ID 223ed0b53f0820ca3d6083c411ca6821127e9408 # Parent 4fe2041007ed78c846a8e9dc284f83c595870620 py3: more robustly cast UUID to bytes The UUID type only has __str__ implemented. So we need to cast to bytes on Python 3. We need an actual bytes instance here (bytestr won't do) because the re.escape() later iterates over characters and characters need to behave like ints, not bytes instances of length 1. Differential Revision: https://phab.mercurial-scm.org/D2144 diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py --- a/mercurial/sshpeer.py +++ b/mercurial/sshpeer.py @@ -220,7 +220,7 @@ def _performhandshake(ui, stdin, stdout, # Generate a random token to help identify responses to version 2 # upgrade request. - token = bytes(uuid.uuid4()) + token = pycompat.sysbytes(str(uuid.uuid4())) upgradecaps = [ ('proto', wireprotoserver.SSHV2), ]