Submitter | Maciej Fijalkowski |
---|---|
Date | April 1, 2016, 8:09 a.m. |
Message ID | <801aaa7190fc0f1ff7cf.1459498187@brick.arcode.com> |
Download | mbox | patch |
Permalink | /patch/14220/ |
State | Accepted |
Delegated to: | Pierre-Yves David |
Headers | show |
Comments
On 04/01/2016 01:09 AM, Maciej Fijalkowski wrote: > # HG changeset patch > # User Maciej Fijalkowski <fijall@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,
Patch
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):