check-code: reject module-level @cachefunc
Module-level @cachefunc usage is risky because it can easily create a
memory "leak". Let's reject it completely for now. If a valid usage
comes up in the future, we can always improve the check or reconsider.
--- a/contrib/check-code.py Fri Jan 13 11:42:36 2017 -0800
+++ b/contrib/check-code.py Fri Jan 13 10:11:37 2017 -0800
@@ -325,6 +325,7 @@
# XXX only catch mutable arguments on the first line of the definition
(r'def.*[( ]\w+=\{\}', "don't use mutable default arguments"),
(r'\butil\.Abort\b', "directly use error.Abort"),
+ (r'^@(\w*\.)?cachefunc', "module-level @cachefunc is risky, please avoid"),
(r'^import Queue', "don't use Queue, use util.queue + util.empty"),
(r'^import cStringIO', "don't use cStringIO.StringIO, use util.stringio"),
(r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"),