changeset 36625:edd3974bd500

py3: do not pass a memoryview to bdiff.bdiff() This doesn't look nice, but I don't know how to make a zero-copy slice of bytes which is compatible with the buffer protocol.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Mar 2018 07:24:25 -0500
parents 3118766266ae
children 6754d0c5e1b5
files mercurial/mdiff.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/mdiff.py	Sat Mar 03 07:00:37 2018 -0500
+++ b/mercurial/mdiff.py	Sat Mar 03 07:24:25 2018 -0500
@@ -30,9 +30,17 @@
 fixws = bdiff.fixws
 patches = mpatch.patches
 patchedsize = mpatch.patchedsize
-textdiff = bdiff.bdiff
+_textdiff = bdiff.bdiff
 splitnewlines = bdiff.splitnewlines
 
+# On Python 3, util.buffer() creates a memoryview, which appears not
+# supporting the buffer protocol
+if pycompat.ispy3:
+    def textdiff(a, b):
+        return _textdiff(bytes(a), bytes(b))
+else:
+    textdiff = _textdiff
+
 class diffopts(object):
     '''context is the number of context lines
     text treats all files as text