util: use fakebuffer as buffer in py3k
authorRenato Cunha <renatoc@gmail.com>
Wed, 14 Jul 2010 22:59:57 -0300
changeset 11566 4d11fde55cc5
parent 11565 7546d4a272c8
child 11567 34cc8b84407f
util: use fakebuffer as buffer in py3k There's no buffer type in py3k, util.py has a function, called fakebuffer, that implements a similar API. This patch implements fakebuffer as a memoryview wrapper in py3k.
mercurial/util.py
--- a/mercurial/util.py	Wed Jul 14 22:59:43 2010 -0300
+++ b/mercurial/util.py	Wed Jul 14 22:59:57 2010 -0300
@@ -38,8 +38,12 @@
 
 import __builtin__
 
-def fakebuffer(sliceable, offset=0):
-    return sliceable[offset:]
+if sys.version_info[0] < 3:
+    def fakebuffer(sliceable, offset=0):
+        return sliceable[offset:]
+else:
+    def fakebuffer(sliceable, offset=0):
+        return memoryview(sliceable)[offset:]
 try:
     buffer
 except NameError: