[PATCH 4 of 9] util.py: use fakebuffer as buffer in py3k
Gilles Moris
gilles.moris at free.fr
Thu Jul 15 02:23:34 CDT 2010
On Thursday 15 July 2010 04:18:37 am Renato Cunha wrote:
> # HG changeset patch
> # User Renato Cunha <renatoc at gmail.com>
> # Date 1279159197 10800
> # Branch stable
> # Node ID 12c5cab6b8b8594f6b3df9833bee0b4fc59e49ee
> # Parent f1975eb501930bb8f3cb56ceac2eb7137d9a8c57
> util.py: 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.
>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -38,8 +38,12 @@
>
> import __builtin__
>
> -def fakebuffer(sliceable, offset=0):
> - return sliceable[offset:]
> +if sys.version_info[0] != 3:
For the future, may be
if sys.version_info[0] < 3:
Regards.
Gilles.
> + def fakebuffer(sliceable, offset=0):
> + return sliceable[offset:]
> +else:
> + def fakebuffer(sliceable, offset=0):
> + return memoryview(sliceable)[offset:]
> try:
> buffer
> except NameError:
More information about the Mercurial-devel
mailing list