Mercurial > hg-stable
comparison mercurial/smartset.py @ 40233:6309128ff61f
py3: use __code__ instead of func_code to test if func is cachable
Surprisingly, this fixes test-cache-abuse.t, which would generate a different
revbranch cache if filtered set had no cache.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 13 Oct 2018 11:01:38 +0200 |
parents | e7aa113b14f7 |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
40232:d99a588d8515 | 40233:6309128ff61f |
---|---|
135 boolean. Optional `condrepr` provides a printable representation of | 135 boolean. Optional `condrepr` provides a printable representation of |
136 the given `condition`. | 136 the given `condition`. |
137 | 137 |
138 This is part of the mandatory API for smartset.""" | 138 This is part of the mandatory API for smartset.""" |
139 # builtin cannot be cached. but do not needs to | 139 # builtin cannot be cached. but do not needs to |
140 if cache and util.safehasattr(condition, 'func_code'): | 140 if cache and util.safehasattr(condition, '__code__'): |
141 condition = util.cachefunc(condition) | 141 condition = util.cachefunc(condition) |
142 return filteredset(self, condition, condrepr) | 142 return filteredset(self, condition, condrepr) |
143 | 143 |
144 def slice(self, start, stop): | 144 def slice(self, start, stop): |
145 """Return new smartset that contains selected elements from this set""" | 145 """Return new smartset that contains selected elements from this set""" |