[PyQt] Compiler Error using SIP: error C3861: 'PyUnicode_FromFormat': identifier not found

Jamie Riotto jamie.riotto at gmail.com
Mon Oct 26 16:16:57 GMT 2009


Phil,
Thanks for the pointer. It looks like PyUnicode_FromFormat()  was
added in Python 3.0,
and I missed the following lines in QPoint.h which explains that:

#if PY_MAJOR_VERSION >=3
     PyUnicode_FromFormat
#else
      PyString_FromFormat


Now I just have to work around the fact that PyString doesn't support
conversion to floats!
(Looks like that is fixed in 3.0 also...)
Thanks, back to compiling - jamie


On Mon, Oct 26, 2009 at 1:05 AM, Phil Thompson
<phil at riverbankcomputing.com> wrote:
> On Sun, 25 Oct 2009 14:45:44 -0700, Jamie Riotto <jamie.riotto at gmail.com>
> wrote:
>> Hi,
>> I'm trying to learn to use SIP, and I've started out with a simple
>> Vector class. The sip file looks like this:
>>
>>
> ===========================================================================
>> %Module Vec3 0
>>
>> class Vec3 {
>>
>> %TypeHeaderCode
>> #include "Vec3.h"
>> %End
>>
>> public:
>>
>>       float x;
>>       float y;
>>       float z;
>>
>>       Vec3();
>>       Vec3(float xpos,float ypos,float zpos);
>>       float getX();
>>       float getY();
>>       float getZ();
>>       SIP_PYOBJECT __repr__() const;
>> %MethodCode
>>       sipRes = PyUnicode_FromFormat("Vec3(%f, %f, %f)", sipCpp->getX(),
>> sipCpp->getY(), sipCpp->getZ());
>> %End
>> };
>>
>>
> ==============================================================================
>>
>> The __repr__ section is my frist attempt at implementing python
>> functions (operators next). I've used QPoint.h and QPoint.sip
>> as my starting point. The c++ code compiles ok , but when I try to
>> compile SIP with the following makefile,
>>
>> I get the following error:
>>
>> sipvec3Vec3.cpp
>> vec3.sip(26): error C3861: 'PyUnicode_FromFormat': identifier not found
>>
>> Any suggestions? Thanks - jamie
>
> If you look up PyUnicode_FromFormat() in the Python docs you will see that
> there is no such function.
>
> There is PyUnicode_Format() but make sure you call it properly.
>
> Phil
>



More information about the PyQt mailing list