[PyQt] SystemError with a temporary variable when accessing a non-existing attribute

Erick Tryzelaar idadesub at users.sourceforge.net
Sat Jul 12 04:45:24 BST 2008


Good evening, I'm getting an interesting error with sip and pointers.
Here's my trimmed down code:

--------------------------------------------------------
#ifndef FOO_H
#define FOO_H

#include <QDebug>

class Foo
{
public:
    Foo() {}
    virtual ~Foo() { qDebug() << "Foo::~Foo"; }
};

class Bar: public Foo
{
public:
    Bar(Foo* foo):foo(foo) {}
    virtual ~Bar() { qDebug() << "Bar::~Bar"; delete foo; }

private:
    Foo* foo;
};

#endif
--------------------------------------------------------

And my sip code:

--------------------------------------------------------
%Module _jazz 0

class Foo
{
%TypeHeaderCode
#include "../foo.h"
%End

public:
  Foo();
  virtual ~Foo();
};

class Bar: Foo
{
%TypeHeaderCode
#include "../foo.h"
%End

public:
  Bar(Foo* foo /Transfer/);
  virtual ~Bar();
};
--------------------------------------------------------


And when used like this, I get this error:

>>> import _jazz
>>> print _jazz.Bar(_jazz.Foo()).foo
Bar::~Bar
Foo::~Foo
Foo::~Foo
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
SystemError: error return without exception set


What am I doing wrong? Thanks for the help.


More information about the PyQt mailing list