Message123479
| Author |
belopolsky |
| Recipients |
Arfrever, amaury.forgeotdarc, belopolsky, ezio.melotti, lemburg, loewis, ronaldoussoren, vstinner |
| Date |
2010年12月06日.16:52:28 |
| SpamBayes Score |
2.569683e-06 |
| Marked as misclassified |
No |
| Message-id |
<1291654350.01.0.246385970547.issue6697@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|