[PyKDE] PyQt segfault with QStringList
Phil Thompson
phil at riverbankcomputing.co.uk
Mon Jul 21 00:56:00 BST 2003
On Sunday 20 July 2003 8:43 pm, Torsten Marek wrote:
> Hello,
>
> is it an intended behaviour, that
>
> ### -- code --
> from qt import *
> class Test:
> def __init__(self):
> self.str = QStringList.split(".", "test.tst")[0]
> def test(self):
> print self.str
> ### -- code --
>
> segfaults? It is obvious that self.str does not "steal" a reference, and
> that can be easily circumvented by putting QStringList(....)[0] into a
> QString constructor, but I do think that this behaviour is not very
> intuitive.
But it is the behaviour at the C++ level where you would also call the QString
ctor with the result.
> The operator[](*) functions of QStringList return sipMapCppToSelf(...),
> is it possible to call Py_INCREF on them? Or is it impossible due to the
> implementation of QStringList on C++ level?
To do what you expect the handwritten code implementing QStringList[] would
make a copy using the reference returned - easy to do but would make the
Python behaviour slightly different to the C++ behaviour.
Phil
More information about the PyQt
mailing list