changeset 28718:f103f985ac00

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
author Maciej Fijalkowski <fijall@gmail.com>
date Fri, 01 Apr 2016 10:09:34 +0200
parents c5f212c8ad78
children dd2cf90a3731
files mercurial/revset.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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):