From patchwork Fri Apr 1 08:09:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2] revset: prevent infinite recursion on pypy From: Maciej Fijalkowski X-Patchwork-Id: 14220 Message-Id: <801aaa7190fc0f1ff7cf.1459498187@brick.arcode.com> To: mercurial-devel@mercurial-scm.org Date: Fri, 01 Apr 2016 10:09:47 +0200 # HG changeset patch # User Maciej Fijalkowski # 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):