[PATCH 8 of 9] util.py: Use fakebuffer as buffer in py3k

Martin Geisler mg at lazybytes.net
Fri Jul 2 18:27:24 CDT 2010


Renato Cunha <renatoc at gmail.com> writes:

>  mercurial/util.py |  3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
>
> # HG changeset patch
> # User Renato Cunha <renatoc at gmail.com>
> # Date 1278023223 10800
> # Node ID 1181d758256e0fc2f8033479a98ea39001e2582a
> # Parent  72e426c43985a901c5f3f3f14d55069fbac8106a
> 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 adds fakebuffer as a buffer in
> builtins to permit backwards-compatibility.
>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -42,6 +42,9 @@
>      return sliceable[offset:]
>  if not hasattr(__builtin__, 'buffer'):
>      __builtin__.buffer = fakebuffer
> +if sys.version_info[0] == 3: # XXX: Would be better if we wrapped memoryview
> +    import builtins
> +    builtins.buffer = fakebuffer

The code just above uses '__builtin__' and this code uses 'builtins'.
I've forgotten what the difference is (if any), but the inconsistency
caught my eye... :-)

So please let me know if the difference is on purpose.

-- 
Martin Geisler

Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100703/95a945ca/attachment.pgp>


More information about the Mercurial-devel mailing list