[PyQt] infinite recursion bug in SIP generated code

Phil Thompson phil at riverbankcomputing.com
Sun Nov 2 14:52:24 GMT 2008


On Sun, 2 Nov 2008 10:46:21 +0100, Gerard Vermeulen <gav451 at gmail.com>
wrote:
> Hi,
> 
> I ran into an infinite recursion bug in SIP generated code.
> The bug is present in the latest snapshot but also in the 4.7.7
> release.
> 
> After enabling the sip tracing flags, I get:
> 
> ...
> RGBA sipStandardColor::operator()(double,double,double) const
> (this=0x0158bef0) RGBA
> sipStandardColor::operator()(double,double,double) const
> (this=0x0158bef0) RGBA
> sipStandardColor::operator()(double,double,double) const
> (this=0x0158bef0) Exception RuntimeError: 'maximum recursion depth
> exceeded in __subclasscheck__' in <type 'exceptions.RuntimeError'>
> ignored Exception RuntimeError: 'maximum recursion depth exceeded in
> __subclasscheck__' in <type 'exceptions.RuntimeError'> ignored Error in
> sys.excepthook: RuntimeError: maximum recursion depth exceeded while
> calling a Python object
> 
> Original exception was:
> RuntimeError: maximum recursion depth exceeded while calling a Python
> object Exception RuntimeError: 'maximum recursion depth exceeded while
> calling a Python object' in <type 'exceptions.RuntimeError'> ignored
> RuntimeError
> dealloc_RGBA()
> dealloc_RGBA()
> dealloc_RGBA()
> ...
> 
> 
> The sip file is:
> 
> class Color
> {
> 
> %TypeHeaderCode
> #include <qwt3d_color.h>
> #include <sip_Qwt3DColorVector.h>
> using namespace Qwt3D;
> %End // %TypeHeaderCode
> 
> public:
>     virtual RGBA operator()(double, double, double) const = 0;
>     virtual RGBA operator()(const Triple &) const;
>     virtual ColorVector & createVector(ColorVector &);
>     void destroy() const;
> 
> protected:
>     virtual ~Color();
> 
> }; // class Color
> 
> 
> class StandardColor: Color
> {
> 
> %TypeHeaderCode
> #include <qwt3d_color.h>
> #include <sip_Qwt3DColorVector.h>
> using namespace Qwt3D;
> %End // %TypeHeaderCode
> 
> public:
>     StandardColor(Plot3D * /TransferThis/, unsigned = 100);
>     virtual RGBA operator()(double, double, double) const;
>     void setColorVector(const ColorVector &);
>     void reset(unsigned = 100);
>     void setAlpha(double);
>     ColorVector & createVector(ColorVector &);
> 
> //protected:
> //    ColorVector colors_ /PyName=colors/;
> //    Plot3D * data_ /PyName=data/;
> 
> }; // class StandardColor
> 
> 
> and the Python snippet showing the bug:
> 
>     def setColor(self):
>         i, step = 252, 4
>         colorVector = ColorVector()
>         while (i>=0):
>             colorVector.push_back(RGBA(i/255.0, max((i-60)/255.0, 0.0),
> 0.0)) step -= 1
>             if step == 0:
>                 i -= 4
>                 step = 4
> # BUG:        color = StandardColor(self.plot)
> # BUG:        color.setColorVector(colorVector)
> # BUG:        self.plot.setDataColor(color)
> 
> 
> Uncommenting the "# BUG:" out-commented lines makes the bug show up.
> 
> Regards -- Gerard

Should be fixed in tonight's snapshot.

Thanks,
Phil


More information about the PyQt mailing list