comparison mercurial/revset.py @ 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 639e0f1e8ffa
comparison
equal deleted inserted replaced
28717:c5f212c8ad78 28718:f103f985ac00
2954 return True 2954 return True
2955 return False 2955 return False
2956 2956
2957 def __len__(self): 2957 def __len__(self):
2958 # Basic implementation to be changed in future patches. 2958 # Basic implementation to be changed in future patches.
2959 l = baseset([r for r in self]) 2959 # until this gets improved, we use generator expression
2960 # here, since list compr is free to call __len__ again
2961 # causing infinite recursion
2962 l = baseset(r for r in self)
2960 return len(l) 2963 return len(l)
2961 2964
2962 def sort(self, reverse=False): 2965 def sort(self, reverse=False):
2963 self._subset.sort(reverse=reverse) 2966 self._subset.sort(reverse=reverse)
2964 2967