error using struct content translated with SIP from cpp

Marian Thomsen marian.thomsen at
Sat Dec 18 14:59:51 GMT 2021


I'm searching for a solution for an encoding error (a possible constraint violation) that occures when the following struct is in the data to encode.
I'm trying to pass an ecoded string to company name that turns to garbage. This only happens in the first encoding iteration the next ones are fine (the string is always the same).

typedef unsigned char OSUTF8CHAR;

struct ASN1T_DangerousGoodsExtended {

#include <ITS-Container.h>

   // ...

   const OSUTF8CHAR* companyName; // <- causes the encoding error

   // ...

   ASN1T_DangerousGoodsExtended ();
} ;

This is the code extract of the sip translation:

extern "C" {static PyObject *varget_ASN1T_DangerousGoodsExtended_companyName(void *, PyObject *, PyObject *);}
static PyObject *varget_ASN1T_DangerousGoodsExtended_companyName(void *sipSelf, PyObject *, PyObject *)
    const  ::OSUTF8CHAR*sipVal;
     ::ASN1T_DangerousGoodsExtended *sipCpp = reinterpret_cast< ::ASN1T_DangerousGoodsExtended *>(sipSelf);

    sipVal = sipCpp->companyName;

    if (sipVal == SIP_NULLPTR)
        return Py_None;

    return PyBytes_FromString((char *)sipVal);

extern "C" {static int varset_ASN1T_DangerousGoodsExtended_companyName(void *, PyObject *, PyObject *);}
static int varset_ASN1T_DangerousGoodsExtended_companyName(void *sipSelf, PyObject *sipPy, PyObject *sipPySelf)
    const  ::OSUTF8CHAR*sipVal;
     ::ASN1T_DangerousGoodsExtended *sipCpp = reinterpret_cast< ::ASN1T_DangerousGoodsExtended *>(sipSelf);

    sipVal = (const unsigned char *)sipBytes_AsString(sipPy);

    if (PyErr_Occurred() != SIP_NULLPTR)
        return -1;

    sipCpp->companyName = sipVal;

    sipKeepReference(sipPySelf, -65, sipPy);

    return 0;

If someone has an idea that could help me, I would be greatflul for an answer.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the PyQt mailing list