[PATCH v2] revset: prevent infinite recursion on pypy

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Apr 1 05:19:54 EDT 2016



On 04/01/2016 01:09 AM, Maciej Fijalkowski wrote:
> # HG changeset patch
> # User Maciej Fijalkowski <fijall at gmail.com>
> # Date 1459498174 -7200
> #      Fri Apr 01 10:09:34 2016 +0200
> # Node ID 801aaa7190fc0f1ff7cf00d372581e3c00a8ad38
> # Parent  25025eea0f6bf62d008d128868b53c7829c73297
> revset: prevent infinite recursion on pypy
>
> as explained in the commit, __len__ cannot do [x for x in self] because
> that can potentially call __len__ again, causing infinite recursion
>
> diff -r 25025eea0f6b -r 801aaa7190fc mercurial/revset.py
> --- a/mercurial/revset.py	Thu Mar 31 15:37:21 2016 +0800
> +++ b/mercurial/revset.py	Fri Apr 01 10:09:34 2016 +0200
> @@ -2960,7 +2960,10 @@
>
>       def __len__(self):
>           # Basic implementation to be changed in future patches.
> -        l = baseset([r for r in self])
> +        # until this gets improved, we use generator expression
> +        # here, since list compr is free to call __len__ again
> +        # causing infinite recursion
> +        l = baseset(r for r in self)
>           return len(l)
>
>       def sort(self, reverse=False):

Pushed to the clowncopter.

Cheers,

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list