Alexander Belopolsky <[email protected]> added the comment:
One of the uses of problematic uses of PyUnicode_GetSize() is in Macintosh
Gestalt interface:
/* Convert a 4-char string object argument to an OSType value */
static int
convert_to_OSType(PyObject *v, OSType *pr)
{
uint32_t tmp;
if (!PyUnicode_Check(v) || PyUnicode_GetSize(v) != 4) {
PyErr_SetString(PyExc_TypeError,
"OSType arg must be string of 4 chars");
return 0;
}
memcpy((char *)&tmp, _PyUnicode_AsString(v), 4);
*pr = (OSType)ntohl(tmp);
return 1;
}
(Modules/_gestalt.c:41)
This function seems to require a bytes, not str argument as interpreting 4
UTF-8 bytes as an int makes little sense.
----------
assignee: -> ronaldoussoren
components: +Macintosh
nosy: +ronaldoussoren
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue6697>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com