[PyKDE] Minor bug in ModuleParser.py handling of nested scopes
with self. references...
Detlev Offenbach
detlev at die-offenbachs.de
Fri Sep 17 17:33:21 BST 2004
Am Freitag, 17. September 2004 04:32 schrieb Mike C. Fletcher:
> This rather common Twisted idiom causes the "Application diagram" plugin
> to choke on line 328 of ModuleParser:
>
> class Test(object):
> def connect(self ):
> """Connect to the remote host, returns deferred returning
> protocol"""
> df = ncrprotocol.connectTCP( self.host, self.port )
> def setProtocol(result):
> self.protocol= result
> return result
> df.addCallback( setProtocol )
> df.addCallback( self.authorizeProtocol )
> return df
>
> To reproduce, save given code in a file, add to a new project and select
> Project|Diagrams|Application Diagram .
>
> Haven't spelunked too deeply in the code, looks like the "Method"
> group-handler needs to look to see if it's defining a nested function
> within a class' method to decide which class to use. Alternately, in
> the Attribute handler, search up the class-definition hierarchy looking
> for the nearest class. You should also guard against potential failures
> where self. is used in functions which aren't defined within a class
> (i.e. they are mixed into a class later):
>
> def another( self ):
> self.x = 3
>
> will cause the same problems for with the Application diagram as the
> previous example.
>
This exeample codes seems to cause some unwanted behaviour (no crash) which I
have to have a look into.
Detlev
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the PyQt
mailing list