strings to CF strings. Fixes 682215.
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
- PyErr_SetString(PyExc_NotImplementedError, \
- "Not available in this shared library/OS version"); \
- return NULL; \
+ PyErr_SetString(PyExc_NotImplementedError, \
+ "Not available in this shared library/OS version"); \
+ return NULL; \
}} while(0)
if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyString_Check(v)) {
char *cStr = PyString_AsString(v);
- *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0);
+ *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII);
return 1;
}
if (PyUnicode_Check(v)) {
Out("""
if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyString_Check(v)) {
- char *cStr = PyString_AsString(v);
- *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0);
+ char *cStr;
+ if (!PyArg_Parse(v, "et", "ascii", &cStr))
+ return NULL;
+ *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII);
return 1;
}
if (PyUnicode_Check(v)) {
UniChar *unichars;
if (PyString_Check(src)) {
- if ((chars = PyString_AsString(src)) == NULL ) goto err;
- *dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, 0);
+ if (!PyArg_Parse(src, "es", NULL, &chars))
+ return NULL; /* This error is more descriptive than the general one below */
+ *dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, kCFStringEncodingASCII);
return 1;
}
if (PyUnicode_Check(src)) {