PyErr_SetString(Error, "unsupported locale setting");
return NULL;
}
- result_object = PyString_FromString(result);
+ result_object = PyUnicode_FromString(result);
if (!result_object)
return NULL;
} else {
PyErr_SetString(Error, "locale query failed");
return NULL;
}
- result_object = PyString_FromString(result);
+ result_object = PyUnicode_FromString(result);
}
return result_object;
}
involved herein */
#define RESULT_STRING(s)\
- x = PyString_FromString(l->s);\
+ x = PyUnicode_FromString(l->s);\
if (!x) goto failed;\
PyDict_SetItemString(result, #s, x);\
Py_XDECREF(x)
#else
PyObject *os1, *os2, *result = NULL;
wchar_t *ws1 = NULL, *ws2 = NULL;
- int rel1 = 0, rel2 = 0, len1, len2;
+ int len1, len2;
if (!PyArg_UnpackTuple(args, "strcoll", 2, 2, &os1, &os2))
return NULL;
- /* If both arguments are byte strings, use strcoll. */
- if (PyString_Check(os1) && PyString_Check(os2))
- return PyInt_FromLong(strcoll(PyString_AS_STRING(os1),
- PyString_AS_STRING(os2)));
- /* If neither argument is unicode, it's an error. */
- if (!PyUnicode_Check(os1) && !PyUnicode_Check(os2)) {
+ /* Both arguments must be unicode, or it's an error. */
+ if (!PyUnicode_Check(os1) || !PyUnicode_Check(os2)) {
PyErr_SetString(PyExc_ValueError, "strcoll arguments must be strings");
}
- /* Convert the non-unicode argument to unicode. */
- if (!PyUnicode_Check(os1)) {
- os1 = PyUnicode_FromObject(os1);
- if (!os1)
- return NULL;
- rel1 = 1;
- }
- if (!PyUnicode_Check(os2)) {
- os2 = PyUnicode_FromObject(os2);
- if (!os2) {
- Py_DECREF(os1);
- return NULL;
- }
- rel2 = 1;
- }
/* Convert the unicode strings to wchar[]. */
len1 = PyUnicode_GET_SIZE(os1) + 1;
ws1 = PyMem_MALLOC(len1 * sizeof(wchar_t));
/* Deallocate everything. */
if (ws1) PyMem_FREE(ws1);
if (ws2) PyMem_FREE(ws2);
- if (rel1) {
- Py_DECREF(os1);
- }
- if (rel2) {
- Py_DECREF(os2);
- }
return result;
#endif
}
return PyErr_NoMemory();
strxfrm(buf, s, n2);
}
- result = PyString_FromString(buf);
+ result = PyUnicode_FromString(buf);
PyMem_Free(buf);
return result;
}
return NULL;
/* Check whether this is a supported constant. GNU libc sometimes
returns numeric values in the char* return value, which would
- crash PyString_FromString. */
+ crash PyUnicode_FromString. */
for (i = 0; langinfo_constants[i].name; i++)
if (langinfo_constants[i].value == item) {
/* Check NULL as a workaround for GNU libc's returning NULL
char *in;
if (!PyArg_ParseTuple(args, "z", &in))
return 0;
- return PyString_FromString(gettext(in));
+ return PyUnicode_FromString(gettext(in));
}
PyDoc_STRVAR(dgettext__doc__,
char *domain, *in;
if (!PyArg_ParseTuple(args, "zz", &domain, &in))
return 0;
- return PyString_FromString(dgettext(domain, in));
+ return PyUnicode_FromString(dgettext(domain, in));
}
PyDoc_STRVAR(dcgettext__doc__,
int category;
if (!PyArg_ParseTuple(args, "zzi", &domain, &msgid, &category))
return 0;
- return PyString_FromString(dcgettext(domain,msgid,category));
+ return PyUnicode_FromString(dcgettext(domain,msgid,category));
}
PyDoc_STRVAR(textdomain__doc__,
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
- return PyString_FromString(domain);
+ return PyUnicode_FromString(domain);
}
PyDoc_STRVAR(bindtextdomain__doc__,
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
- return PyString_FromString(dirname);
+ return PyUnicode_FromString(dirname);
}
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
return NULL;
codeset = bind_textdomain_codeset(domain, codeset);
if (codeset)
- return PyString_FromString(codeset);
+ return PyUnicode_FromString(codeset);
Py_RETURN_NONE;
}
#endif