In the following code, I am trying to pack two null-terminated C strings (char pointers) into a Python tuple.
printf("word1 = '%s', word2 = '%s'\n", words1->wordArray[i], words2->wordArray[i]);
cmpArgs = Py_BuildValue("ss", words1->wordArray[i], words2->wordArray[i]);
printf("%s\n", PyString_AsString(PyTuple_GetItem(cmpArgs, 0)));
This produces output like:
word1 = '20', word2 = '20'
iā“
Why is the string different in the tuple than outside it? What am I doing wrong? Also, do I need to worry about incrementing and decrementing the reference count of this tuple? (I am creating it to pass to a Python function passed to C as a PyObject*)