On 06.04.07 12:25:31, Phil Thompson wrote: > On Friday 06 April 2007 11:43 am, Andreas Pakulat wrote: > > On 06.04.07 10:44:13, Phil Thompson wrote: > > > On Friday 06 April 2007 10:10 am, Andreas Pakulat wrote: > > > > I've put an PyErr_Print(); into the if-part and here's the output (the > > > > object parsing block is printed when in QtCore the 2nd block with the > > > > pointer is executed). So as far as I can see the problem is that id() > > > > returns a long int, but its going to be converted to an int and that > > > > fails... > > > > > > > > emodel>python simpletreemodel.py > > > > .... > > > > ------------------------- > > > > OverflowError: long int too large to convert to int > > > > ------------------------- > > > > Object parsing block > > > > ------------------------- > > > > OverflowError: long int too large to convert to int > > > > ------------------------- > > > > Object parsing block > > > > ------------------------- > > > > OverflowError: long int too large to convert to int > > > > ------------------------- > > > > Object parsing block > > > > > > And I guess if you change the call to PyLong_AsLong() instead of > > > PyInt_AsLong() then it would call the right overload. > > > > Uhm, no. Just changing the PyInt_AsLong to PyLong_AsLong gives new > > errors. You know I don't really know what I'm doing here, I have no idea > > how sip itself works or how wrapping C++ code with sip works... > > What new errors?
Uhm, lets see if I find them again without changing sip again :) Not sure where the first one comes from, but the other three are from createIndex calls. ------------------------- SystemError: Objects/longobject.c:211: bad argument to internal function ------------------------- ------------------------- OverflowError: long int too large to convert to int ------------------------- Object parsing block ------------------------- OverflowError: long int too large to convert to int ------------------------- Object parsing block ------------------------- OverflowError: long int too large to convert to int ------------------------- Object parsing block > > > So the question is... > > > > > > Should SIP quietly lose the extra bits, or should it raise an exception. > > > > Well, unless I'm mistaken this would still mean that internalId() != > > id(object), if id() returns a value that is outside the int-range. So I > > don't think thats a good solution. > > But it's the "correct" solution as a C++ application would have the same > problem. In C++ there's no id() function that I'm aware of. However yes, if you calculate an id for the objects in the tree that uses a long instead of an int or better qint32 then its the same problem in C++. > > Also if internalPointer works properly I don't think the id-thing is > > needed. After all with the pointer you don't necessarily need to keep > > the list around if you create a tree structure with your objects. > > Yes. With hindsight I shouldn't have wrapped the first createIndex() overload > and internalId() in the first place, but at the time I wrapped the second > overload and internalPointer() as using a void* instead of a Python object > which made it unusable. BTW: Changing eric4's code I again have a segfault, possibly due to some object not having a reference to it anymore (after changing the code to use internalPointer only). Andreas -- Excellent time to become a missing person. _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
