summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/pychecker/files')
-rw-r--r--dev-python/pychecker/files/digest-pychecker-0.8.173
-rw-r--r--dev-python/pychecker/files/digest-pychecker-0.8.17-r13
-rw-r--r--dev-python/pychecker/files/pychecker-0.8.17.std_lib.patch70
-rw-r--r--dev-python/pychecker/files/pychecker.blacklist.patch18
-rw-r--r--dev-python/pychecker/files/pychecker.classObject__name__.patch32
-rw-r--r--dev-python/pychecker/files/pychecker.getModules.patch175
-rw-r--r--dev-python/pychecker/files/pychecker.lambda-assign.patch29
7 files changed, 330 insertions, 0 deletions
diff --git a/dev-python/pychecker/files/digest-pychecker-0.8.17 b/dev-python/pychecker/files/digest-pychecker-0.8.17
new file mode 100644
index 0000000..4105c36
--- /dev/null
+++ b/dev-python/pychecker/files/digest-pychecker-0.8.17
@@ -0,0 +1,3 @@
+MD5 9d2a2d62b368ce503830f830a89bd230 pychecker-0.8.17.tar.gz 130689
+RMD160 16a83bcbd45b14fd5fb786e7a8ce52c7ecc87eb6 pychecker-0.8.17.tar.gz 130689
+SHA256 7ee4ea2fc02151196590cdef6073302dd61156503ee242a68a3c8aff50e86e52 pychecker-0.8.17.tar.gz 130689
diff --git a/dev-python/pychecker/files/digest-pychecker-0.8.17-r1 b/dev-python/pychecker/files/digest-pychecker-0.8.17-r1
new file mode 100644
index 0000000..4105c36
--- /dev/null
+++ b/dev-python/pychecker/files/digest-pychecker-0.8.17-r1
@@ -0,0 +1,3 @@
+MD5 9d2a2d62b368ce503830f830a89bd230 pychecker-0.8.17.tar.gz 130689
+RMD160 16a83bcbd45b14fd5fb786e7a8ce52c7ecc87eb6 pychecker-0.8.17.tar.gz 130689
+SHA256 7ee4ea2fc02151196590cdef6073302dd61156503ee242a68a3c8aff50e86e52 pychecker-0.8.17.tar.gz 130689
diff --git a/dev-python/pychecker/files/pychecker-0.8.17.std_lib.patch b/dev-python/pychecker/files/pychecker-0.8.17.std_lib.patch
new file mode 100644
index 0000000..5ddb59c
--- /dev/null
+++ b/dev-python/pychecker/files/pychecker-0.8.17.std_lib.patch
@@ -0,0 +1,70 @@
+Index: pychecker-0.8.17/pychecker/warn.py
+===================================================================
+--- pychecker-0.8.17.orig/pychecker/warn.py
++++ pychecker-0.8.17/pychecker/warn.py
+@@ -391,16 +391,26 @@ def getBlackList(moduleList) :
+ pass
+ return blacklist
+
+-def getStandardLibrary() :
++def getStandardLibraries() :
++ """
++ Return a list of standard libraries.
++
++ @rtype: list of str or None
++ """
+ if cfg().ignoreStandardLibrary :
+ try :
+ from distutils import sysconfig
+
+- std_lib = sysconfig.get_python_lib()
+- path = os.path.split(std_lib)
+- if path[1] == 'site-packages' :
+- std_lib = path[0]
+- return std_lib
++ std_libs = [
++ sysconfig.get_python_lib(plat_specific=0),
++ sysconfig.get_python_lib(plat_specific=1)
++ ]
++ ret = []
++ for std_lib in std_libs:
++ path = os.path.split(std_lib)
++ if path[1] == 'site-packages' :
++ ret.append(path[0])
++ return ret
+ except ImportError :
+ return None
+
+@@ -409,12 +419,20 @@ def normalize_path(path):
+
+ def removeWarnings(warnings, blacklist, std_lib, cfg):
+ if std_lib is not None:
+- std_lib = normalize_path(std_lib)
++ std_lib = [normalize_path(p) for p in std_lib]
+ for index in range(len(warnings)-1, -1, -1) :
+ filename = normalize_path(warnings[index].file)
+- if filename in blacklist or (std_lib is not None and
+- utils.startswith(filename, std_lib)) :
++ if filename in blacklist:
+ del warnings[index]
++ elif std_lib:
++ found = False
++ for path in std_lib:
++ if utils.startswith(filename, path) :
++ del warnings[index]
++ found = True
++ break
++ if found:
++ continue
+ elif cfg.only:
+ # ignore files not specified on the cmd line if requested
+ if os.path.abspath(filename) not in cfg.files:
+@@ -721,7 +739,7 @@ def find(moduleList, initialCfg, suppres
+
+ std_lib = None
+ if cfg().ignoreStandardLibrary :
+- std_lib = getStandardLibrary()
++ std_lib = getStandardLibraries()
+ return removeWarnings(warnings, getBlackList(cfg().blacklist), std_lib,
+ cfg())
+
diff --git a/dev-python/pychecker/files/pychecker.blacklist.patch b/dev-python/pychecker/files/pychecker.blacklist.patch
new file mode 100644
index 0000000..f78f173
--- /dev/null
+++ b/dev-python/pychecker/files/pychecker.blacklist.patch
@@ -0,0 +1,18 @@
+Index: pychecker/pychecker/checker.py
+===================================================================
+--- pychecker.orig/pychecker/checker.py
++++ pychecker/pychecker/checker.py
+@@ -262,9 +262,10 @@ class Class :
+ self.module = sys.modules.get(modname)
+ if not self.module:
+ self.module = module
+- sys.stderr.write("warning: couldn't find real module "
+- "for class %s (module name: %s)\n"
+- % (self.classObject, modname))
++ if modname not in cfg().blacklist:
++ sys.stderr.write("warning: couldn't find real module "
++ "for class %s (module name: %s)\n"
++ % (self.classObject, modname))
+ self.ignoreAttrs = 0
+ self.methods = {}
+ self.members = { '__class__': types.ClassType,
diff --git a/dev-python/pychecker/files/pychecker.classObject__name__.patch b/dev-python/pychecker/files/pychecker.classObject__name__.patch
new file mode 100644
index 0000000..83bfc0e
--- /dev/null
+++ b/dev-python/pychecker/files/pychecker.classObject__name__.patch
@@ -0,0 +1,32 @@
+? classObject__name__.patch
+Index: pychecker/checker.py
+===================================================================
+--- pychecker/checker.py.orig
++++ pychecker/checker.py
+@@ -248,6 +248,17 @@ class Class :
+ if mo:
+ modname = ".".join(mo.group(1).split(".")[:-1])
+
++ # zope.interface for example has Provides and Declaration that
++ # look a lot like class objects but do not have __name__
++ if hasattr(self.classObject, '__name__'):
++ self.classObject__name__ = self.classObject.__name__
++ else:
++ if modname not in cfg().blacklist:
++ sys.stderr.write("warning: no __name__ attribute "
++ "for class %s (module name: %s)\n"
++ % (self.classObject, modname))
++ self.classObject__name__ = name
++
+ self.module = sys.modules.get(modname)
+ if not self.module:
+ self.module = module
+@@ -329,7 +340,7 @@ class Class :
+ self.cleanupMemberRefs()
+ # add standard methods
+ for methodName in ('__class__',) :
+- self.addMethod(methodName, classObject.__name__)
++ self.addMethod(methodName, self.classObject__name__)
+
+ def addMembers(self, classObject) :
+ if not cfg().onlyCheckInitForMembers :
diff --git a/dev-python/pychecker/files/pychecker.getModules.patch b/dev-python/pychecker/files/pychecker.getModules.patch
new file mode 100644
index 0000000..3a33ebb
--- /dev/null
+++ b/dev-python/pychecker/files/pychecker.getModules.patch
@@ -0,0 +1,175 @@
+Index: pychecker/pychecker/checker.py
+===================================================================
+--- pychecker.orig/pychecker/checker.py
++++ pychecker/pychecker/checker.py
+@@ -99,7 +99,7 @@ def _flattenList(list) :
+ return new_list
+
+ def getModules(arg_list) :
+- "Returns a list of module names that can be imported"
++ "Returns a list of (module names, dirPath) that can be imported"
+
+ new_arguments = []
+ for arg in arg_list :
+@@ -116,6 +116,7 @@ def getModules(arg_list) :
+
+ modules = []
+ for arg in _flattenList(new_arguments) :
++ arg_dir = None # actual modules will not give us a dir to load from
+ # is it a .py file?
+ for suf, suflen in zip(PY_SUFFIXES, PY_SUFFIX_LENS):
+ if len(arg) > suflen and arg[-suflen:] == suf:
+@@ -125,10 +126,12 @@ def getModules(arg_list) :
+ continue
+
+ module_name = os.path.basename(arg)[:-suflen]
+- if arg_dir not in sys.path :
+- sys.path.insert(0, arg_dir)
++ # THOMAS: this breaks loading two .py files with same name
++ # from different dirs; we would always get the first one
++ #if arg_dir not in sys.path :
++ # sys.path.insert(0, arg_dir)
+ arg = module_name
+- modules.append(arg)
++ modules.append((arg, arg_dir))
+
+ return modules
+
+@@ -161,11 +164,13 @@ def _q_find_module(p, path):
+ if os.path.exists(f):
+ return _q_file(file(f)), f, ('.ptl', 'U', 1)
+
+-def _findModule(name) :
++def _findModule(name, moduleDir=None) :
+ """Returns the result of an imp.find_module(), ie, (file, filename, smt)
+ name can be a module or a package name. It is *not* a filename."""
+
+ path = sys.path[:]
++ if moduleDir:
++ path.insert(0, moduleDir)
+ packages = string.split(name, '.')
+ for p in packages :
+ # smt = (suffix, mode, type)
+@@ -235,8 +240,9 @@ def _getClassTokens(c) :
+ class Class :
+ "Class to hold all information about a class"
+
+- def __init__(self, name, module) :
++ def __init__(self, name, pcmodule) :
+ self.name = name
++ module = pcmodule.module
+ self.classObject = getattr(module, name)
+
+ modname = getattr(self.classObject, '__module__', None)
+@@ -260,7 +266,9 @@ class Class :
+ self.classObject__name__ = name
+
+ self.module = sys.modules.get(modname)
+- if not self.module:
++ # if the pcmodule has moduleDir, it means we processed it before,
++ # and deleted it from sys.modules
++ if not self.module and not pcmodule.moduleDir:
+ self.module = module
+ if modname not in cfg().blacklist:
+ sys.stderr.write("warning: couldn't find real module "
+@@ -497,8 +505,13 @@ def _getPyFile(filename):
+ class PyCheckerModule :
+ "Class to hold all information for a module"
+
+- def __init__(self, moduleName, check = 1) :
++ def __init__(self, moduleName, check = 1, moduleDir=None) :
++ """
++ @param moduleDir: if specified, the directory where the module can
++ be loaded from
++ """
+ self.moduleName = moduleName
++ self.moduleDir = moduleDir
+ self.variables = {}
+ self.functions = {}
+ self.classes = {}
+@@ -508,7 +521,12 @@ class PyCheckerModule :
+ self.main_code = None
+ self.module = None
+ self.check = check
+- _allModules[moduleName] = self
++ # FIXME: to make sure we have separate dict entries for different files
++ # with the same module name, we fudge in the moduleDir
++ __name = moduleName
++ if moduleDir:
++ __name = moduleName + moduleDir
++ _allModules[__name] = self
+
+ def __str__(self) :
+ return self.moduleName
+@@ -528,7 +546,9 @@ class PyCheckerModule :
+ c.addMembers(classObject)
+
+ def addClass(self, name) :
+- self.classes[name] = c = Class(name, self.module)
++ #self.classes[name] = c = Class(name, self.module)
++ # give ourselves, so Class has more context
++ self.classes[name] = c = Class(name, self)
+ try:
+ objName = utils.safestr(c.classObject)
+ except TypeError:
+@@ -558,16 +578,19 @@ class PyCheckerModule :
+ filename = self.module.__file__
+ except AttributeError :
+ filename = self.moduleName
++ if self.moduleDir:
++ filename = self.moduleDir + ': ' + filename
+ return _getPyFile(filename)
+
+ def load(self):
+ try :
+- # there's no need to reload modules we already have
+- module = sys.modules.get(self.moduleName)
+- if module :
+- if not _allModules[self.moduleName].module :
+- return self._initModule(module)
+- return 1
++ # there's no need to reload modules we already have if no moduleDir
++ if not self.moduleDir:
++ module = sys.modules.get(self.moduleName)
++ if module :
++ if not _allModules[self.moduleName].module :
++ return self._initModule(module)
++ return 1
+
+ return self._initModule(self.setupMainCode())
+ except (SystemExit, KeyboardInterrupt) :
+@@ -627,9 +650,19 @@ class PyCheckerModule :
+ return 1
+
+ def setupMainCode(self) :
+- file, filename, smt = _findModule(self.moduleName)
++ file, filename, smt = _findModule(self.moduleName, self.moduleDir)
+ # FIXME: if the smt[-1] == imp.PKG_DIRECTORY : load __all__
++ # HACK: to make sibling imports work, we add self.moduleDir to sys.path
++ # temporarily, and remove it later
++ if self.moduleDir:
++ oldsyspath = sys.path[:]
++ sys.path.insert(0, self.moduleDir)
+ module = imp.load_module(self.moduleName, file, filename, smt)
++ if self.moduleDir:
++ sys.path = oldsyspath
++ # to make sure that subsequent modules with the same moduleName
++ # do not persist, and getting their namespace clobbered, delete it
++ del sys.modules[self.moduleName]
+ self._setupMainCode(file, filename, module)
+ return module
+
+@@ -736,10 +769,10 @@ def processFiles(files, cfg = None, pre_
+
+ warnings = []
+ utils.initConfig(_cfg)
+- for moduleName in getModules(files) :
++ for file, (moduleName, moduleDir) in zip(files, getModules(files)) :
+ if callable(pre_process_cb) :
+- pre_process_cb(moduleName)
+- module = PyCheckerModule(moduleName)
++ pre_process_cb("%s (%s)" % (moduleName, file))
++ module = PyCheckerModule(moduleName, moduleDir=moduleDir)
+ if not module.load() :
+ w = Warning(module.filename(), 1,
+ msgs.Internal("NOT PROCESSED UNABLE TO IMPORT"))
diff --git a/dev-python/pychecker/files/pychecker.lambda-assign.patch b/dev-python/pychecker/files/pychecker.lambda-assign.patch
new file mode 100644
index 0000000..0a8bb1e
--- /dev/null
+++ b/dev-python/pychecker/files/pychecker.lambda-assign.patch
@@ -0,0 +1,29 @@
+Index: pychecker/pychecker/CodeChecks.py
+===================================================================
+--- pychecker.orig/pychecker/CodeChecks.py
++++ pychecker/pychecker/CodeChecks.py
+@@ -144,7 +144,10 @@ def _checkBuiltin(code, loadValue, argCo
+ (func_name == 'getattr' and argCount == 2)):
+ arg2 = code.stack[-argCount + 1]
+ if arg2.const:
+- code.addWarning(msgs.USES_CONST_ATTR % func_name)
++ # lambda with setattr and const is a common way of setting
++ # attributes, so allow it
++ if code.func.function.func_name != '<lambda>':
++ code.addWarning(msgs.USES_CONST_ATTR % func_name)
+
+ if kwArgs:
+ _validateKwArgs(code, info, func_name, kwArgs)
+@@ -395,7 +398,11 @@ def _handleFunctionCall(codeSource, code
+ name = utils.safestr(loadValue.data)
+ if type(loadValue.data) == types.TupleType :
+ name = string.join(loadValue.data, '.')
+- code.addWarning(msgs.USING_NONE_RETURN_VALUE % name)
++ # lambda with setattr is a common way of setting
++ # attributes, so allow it
++ if name != 'setattr' \
++ or code.func.function.func_name != '<lambda>':
++ code.addWarning(msgs.USING_NONE_RETURN_VALUE % name)
+
+ code.stack = code.stack[:funcIndex] + [ returnValue ]
+ code.functionsCalled[funcName] = loadValue