revset: prevent infinite recursion on pypy
authorMaciej Fijalkowski <fijall@gmail.com>
Fri, 01 Apr 2016 10:09:34 +0200
changeset 28718 f103f985ac00
parent 28717 c5f212c8ad78
child 28719 dd2cf90a3731
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
mercurial/revset.py
--- a/mercurial/revset.py	Thu Mar 31 18:38:08 2016 +0200
+++ b/mercurial/revset.py	Fri Apr 01 10:09:34 2016 +0200
@@ -2956,7 +2956,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):