views:

32

answers:

0

Our C++ lib works fine with Python2.4 using Swig, returning a C++ char* back to a python str. But this solution hit problem in Python3.0, error is:

Exception=(, UnicodeDecodeError('utf8', b"\xb6\x9d\xa.....",0, 1, 'unexpected code byte')

Our definition is like(working fine in Python 2.4):

void  cGetPubModulus(
 void*  pSslRsa,
    char*  cMod,
    int*   nLen );

%include "cstring.i"
%cstring_output_withsize( char* cMod, int* nLen );

Suspect swig is doing a Bytes->Str conversion automatically. In python2.4 it can be implicit but in Python3.0 it's no long allowed.. Anyone got a good idea? thanks