From: Thomas V. S. <tho...@us...> - 2011-01-25 11:40:09
|
Update of /cvsroot/pychecker/pychecker/pychecker In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5451/pychecker Modified Files: Stack.py pcmodules.py Log Message: * pychecker/Stack.py: Document isMethodCall. Add a FIXME for the fact that we're not checking at all if the item really represents a method known to the classObject passed. It breaks test 69 which does __init__ aliasing. * pychecker/pcmodules.py: Document Class better. Add an assert to make sure that we add by the real name of the method. Index: pcmodules.py =================================================================== RCS file: /cvsroot/pychecker/pychecker/pychecker/pcmodules.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- pcmodules.py 18 Jan 2011 07:42:28 -0000 1.19 +++ pcmodules.py 25 Jan 2011 11:39:59 -0000 1.20 @@ -113,7 +113,7 @@ or because the module this class comes from is blacklisted. @type ignoreAttrs: int (used as bool) - @type methods: dict + @type methods: dict of str -> None or L{Function} @type members: dict of str -> type @type memberRefs: dict @type statics: dict @@ -211,6 +211,8 @@ def addMethod(self, methodName, method=None): """ Add the given method to this class by name. + The name is the real name of the method, not an alias; ie the name of + the method as defined in the code. @type methodName: str @type method: method or None @@ -218,6 +220,7 @@ if not method: self.methods[methodName] = None else : + assert method.func_name == methodName self.methods[methodName] = function.Function(method, 1) def addMethods(self, classObject): Index: Stack.py =================================================================== RCS file: /cvsroot/pychecker/pychecker/pychecker/Stack.py,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- Stack.py 25 Jan 2011 10:32:24 -0000 1.28 +++ Stack.py 25 Jan 2011 11:39:59 -0000 1.29 @@ -73,11 +73,12 @@ def isImplicitNone(self) : return self.data is None and self.const - def isMethodCall(self, c, methodArgName): + def isMethodCall(self, classObject, methodArgName): """ - @param methodArgName: the first argument Check if the stack item is a method call. + @type classObject: L{pychecker.PCModules.Class} or None + @param classObject: the class object to check against @type methodArgName: str @param methodArgName: the name of the first argument for method calls; usually self. @@ -85,9 +86,9 @@ if self.type != TYPE_ATTRIBUTE: return False - # FIXME: we only check if c is not None; that doesn't mean it + # FIXME: we only check if classObject is not None; that doesn't mean it # has the given methodArgName - if c is None: + if classObject is None: return False if len(self.data) != 2: @@ -98,6 +99,14 @@ # indirection does not start with first argument for method calls return False + # FIXME: this check was not happening before; so before it was counting + # object attributes as methods always + if self.data[1] not in classObject.methods: + # FIXME: for now implement previous behaviour, but fix it to return + # False + return True + # return False + return True def isLocals(self): |