Mercurial > hg
changeset 11566:4d11fde55cc5
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.
author | Renato Cunha <renatoc@gmail.com> |
---|---|
date | Wed, 14 Jul 2010 22:59:57 -0300 |
parents | 7546d4a272c8 |
children | 34cc8b84407f |
files | mercurial/util.py |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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: