Re: [Pyobjc-dev] Still struggling with NSOutlineView
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-01-18 12:54:34
|
On Wednesday, Jan 15, 2003, at 23:13 Europe/Amsterdam, Just van Rossum wrote: > I just noticed that my PythonBrowser application doesn't work > correctly after > all if I don't subclass PythonItem from NSObject. I was getting > strange messages > in the log if I tried to unpack certain items: > > 2003-01-15 21:48:37.838 python[13055] PythonItem instance has no > attribute '__getitem__' > > but I was sure *I* didn't do any subscripting on PythonItem instances. > It > appears Cocoa is calling it (*), through PyObjC, and while trying to > find what's > wrong I came across this snippet in Modules/objc/objc_support.m: > > else if (PySequence_Check(argument)) > *(id *) datum = [OC_PythonArray > newWithPythonObject:argument]; > > PySequence_Check() is a lame check, it always returns true for simple > instances. How usefull ;-(. I thought this checked if an object implements a sequence. I did wonder how the code could detect if a __getitem__ method is sequence-like instead of dict-like, but never thought the check would be this lame. I'll convert to check to PyList_Check || PyTuple_Check. > But since there's a PyDict_Check() below (which really checks > isinstance(x, > dict)), I think the following would be better/safer: > > else if (PyList_Check(argument) || PyTuple_Check(argument)) > *(id *) datum = [OC_PythonArray > newWithPythonObject:argument]; > > However, if I make that change, PythonBrowser doesn't run at all > anymore: it > crashes before any window is shown. ... And after this conversion I'll have to do some debugging. Ronald |