[PATCH 2 of 2] py3: use __code__ instead of func_code to test if func is cachable

Yuya Nishihara yuya at tcha.org
Sat Oct 13 05:10:14 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1539421298 -7200
#      Sat Oct 13 11:01:38 2018 +0200
# Node ID 3475487059e51d5ef768f5d2ade29bddf6bbd21f
# Parent  7e85eb3b267f431106e6f523786712ca6a9ec4df
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.

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -48,6 +48,7 @@ test-bundle2-format.t
 test-bundle2-multiple-changegroups.t
 test-bundle2-pushback.t
 test-bundle2-remote-changegroup.t
+test-cache-abuse.t
 test-cappedreader.py
 test-casecollision.t
 test-cat.t
diff --git a/mercurial/smartset.py b/mercurial/smartset.py
--- a/mercurial/smartset.py
+++ b/mercurial/smartset.py
@@ -137,7 +137,7 @@ class abstractsmartset(object):
 
         This is part of the mandatory API for smartset."""
         # builtin cannot be cached. but do not needs to
-        if cache and util.safehasattr(condition, 'func_code'):
+        if cache and util.safehasattr(condition, '__code__'):
             condition = util.cachefunc(condition)
         return filteredset(self, condition, condrepr)
 


More information about the Mercurial-devel mailing list