Re: [Pyobjc-dev] __dict__?
Brought to you by:
ronaldoussoren
From: Martina O. <Ma...@Oe...> - 2003-10-23 19:11:33
|
IHMO, that's a PyObjC feature, not a bug. New style classes with __slots__ also don't have a __dict__, so PyUMLGraph won't work with them, too: >>> class C(object): ... __slots__=[] ... >>> x=C() >>> x.__dict__ Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'C' object has no attribute '__dict__' PyUMLGraph should use dir instead - this works with both new and old-style classes: >>> dir(x) ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__slots__', '__str__'] Am Dienstag, 21.10.03 um 07:58 Uhr schrieb b.bum: > http://www.pobox.com/~adamf/software/PyUMLGraph > > (graphviz installs fine via Fink, btw.) > > I was playing with PyUMLGraph (cool stuff) and ran it against a PyObjC > example. It breaks with the following which raises the question as to > whether or not we should have a __dict__ attribute on the Python side > of the bridge and, if so, what it should be populated with. > > [administrators-computer:sourceforge/pyobjc/Examples] bbum% pyumlgraph > --types --nodefillcolor="#ffcc19" -o subclassing-objective-c.dot > subclassing-objective-c.py > <native-selector alloc of <objective-c class Demo at 0x325020>> > Traceback (most recent call last): > File > "/System/Library/Frameworks/Python.framework/Versions/Current/bin/ > pyumlgraph", line 139, in ? > main() > File > "/System/Library/Frameworks/Python.framework/Versions/Current/bin/ > pyumlgraph", line 126, in main > umlGrapher.run('execfile(' + `progname` + ')') > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/site-packages/PyUMLGraph/UmlGrapher.py", line 16, in run > exec cmd in dict, dict > File "<string>", line 1, in ? > File "subclassing-objective-c.py", line 31, in ? > x = Demo.alloc().init() > File "subclassing-objective-c.py", line 15, in init > def init(self): > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/site-packages/PyUMLGraph/InfoCollector.py", line 48, in > globalTrace > self.collectInfo(frame, event, arg) > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/site-packages/PyUMLGraph/InfoCollector.py", line 65, in > collectInfo > self.collectInfoForClass(className, frame, event, arg) > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/site-packages/PyUMLGraph/InfoCollector.py", line 82, in > collectInfoForClass > classInfo.collectInfo(frame, event, arg) > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/site-packages/PyUMLGraph/ClassInfo.py", line 53, in > collectInfo > self.selfReferences.collectInfo(frame, event, arg) > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/site-packages/PyUMLGraph/SelfReferencesGatherer.py", line > 17, in collectInfo > attributes = self.getInstanceAttributes(frame.f_locals["self"]) > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/site-packages/PyUMLGraph/Gatherer.py", line 36, in > getInstanceAttributes > return object.__dict__ > AttributeError: 'Demo' object has no attribute '__dict__' > > > > ------------------------------------------------------- > This SF.net email is sponsored by: The SF.net Donation Program. > Do you like what SourceForge.net is doing for the Open > Source Community? Make a contribution, and help us add new > features and functionality. Click here: http://sourceforge.net/donate/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > ciao Martina |