summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-09 11:17:33 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-09 11:17:33 (GMT)
commit5e23d5732b8e549588be7b0cc7c3deeb300df7e0 (patch)
tree7cc134febc1e771719f8e62373e421e9a3d9c97a /Python
parent9a63470fd7f1d96eff03ffd33bf75371d5bb6fac (diff)
downloadcpython-5e23d5732b8e549588be7b0cc7c3deeb300df7e0.zip
cpython-5e23d5732b8e549588be7b0cc7c3deeb300df7e0.tar.gz
cpython-5e23d5732b8e549588be7b0cc7c3deeb300df7e0.tar.bz2
Changes to ctypes and Mac toolbox glue that fix test_threading and test_platform.
However, test_ctypes is still broken -- and apparently more than before.
Diffstat (limited to 'Python')
-rw-r--r--Python/mactoolboxglue.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/Python/mactoolboxglue.c b/Python/mactoolboxglue.c
index 26a1308..9a8d30b 100644
--- a/Python/mactoolboxglue.c
+++ b/Python/mactoolboxglue.c
@@ -159,12 +159,32 @@ int
PyMac_GetOSType(PyObject *v, OSType *pr)
{
uint32_t tmp;
- if (!PyString_Check(v) || PyString_Size(v) != 4) {
+ const char *str;
+ int len;
+ if (PyUnicode_Check(v)) {
+ v = _PyUnicode_AsDefaultEncodedString(v, NULL);
+ if (v == NULL)
+ return 0;
+ }
+ if (PyString_Check(v)) {
+ str = PyString_AS_STRING(v);
+ len = PyString_GET_SIZE(v);
+ }
+ else if (PyBytes_Check(v)) {
+ str = PyBytes_AS_STRING(v);
+ len = PyBytes_GET_SIZE(v);
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "OSType arg must be string (of 4 chars)");
+ return 0;
+ }
+ if (len != 4) {
PyErr_SetString(PyExc_TypeError,
- "OSType arg must be string of 4 chars");
+ "OSType arg must be (string of) 4 chars");
return 0;
}
- memcpy((char *)&tmp, PyString_AsString(v), 4);
+ memcpy((char *)&tmp, str, 4);
*pr = (OSType)ntohl(tmp);
return 1;
}