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

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 13, 2018, 9:10 a.m.
Message ID <3475487059e51d5ef768.1539421814@mimosa>
Download mbox | patch
Permalink /patch/35845/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 13, 2018, 9:10 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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)