Issue 35384: The repr of ctypes.CArgObject fails for non-ascii character (original) (raw)
The repr of the ctypes.CArgObject instance will fail when the value is a non-ascii character.
The code is:
sprintf(buffer, "<cparam '%c' (%c)>",
self->tag, self->value.c);
...
return PyUnicode_FromString(buffer);
If self->value.c is out of range 0-127, buffer will contain a string not decodable with UTF-8.
There is a similar problem with non-ascii self->tag.
The following PR is purposed to fix this, but I don't know how to test it. Current tests only create CArgObject instances with tag='P' (in byref()).