mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
PyUnicode_AsWideCharString() takes a PyObject*, not a PyUnicodeObject*
All unicode functions uses PyObject* except PyUnicode_AsWideChar(). Fix the prototype for the new function PyUnicode_AsWideCharString().
This commit is contained in:
parent
ef12810f0c
commit
beb4135b8c
9 changed files with 14 additions and 14 deletions
|
@ -462,7 +462,7 @@ wchar_t support for platforms which support it:
|
||||||
required by the application.
|
required by the application.
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: wchar_t* PyUnicode_AsWideCharString(PyUnicodeObject *unicode, Py_ssize_t *size)
|
.. c:function:: wchar_t* PyUnicode_AsWideCharString(PyObject *unicode, Py_ssize_t *size)
|
||||||
|
|
||||||
Convert the Unicode object to a wide character string. The output string
|
Convert the Unicode object to a wide character string. The output string
|
||||||
always ends with a nul character. If *size* is not *NULL*, write the number
|
always ends with a nul character. If *size* is not *NULL*, write the number
|
||||||
|
|
|
@ -581,7 +581,7 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
|
||||||
MemoryError. */
|
MemoryError. */
|
||||||
|
|
||||||
PyAPI_FUNC(wchar_t*) PyUnicode_AsWideCharString(
|
PyAPI_FUNC(wchar_t*) PyUnicode_AsWideCharString(
|
||||||
PyUnicodeObject *unicode, /* Unicode object */
|
PyObject *unicode, /* Unicode object */
|
||||||
Py_ssize_t *size /* number of characters of the result */
|
Py_ssize_t *size /* number of characters of the result */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -666,7 +666,7 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
pa->ffi_type = &ffi_type_pointer;
|
pa->ffi_type = &ffi_type_pointer;
|
||||||
pa->value.p = PyUnicode_AsWideCharString((PyUnicodeObject *)obj, NULL);
|
pa->value.p = PyUnicode_AsWideCharString(obj, NULL);
|
||||||
if (pa->value.p == NULL)
|
if (pa->value.p == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
pa->keep = PyCapsule_New(pa->value.p, CTYPES_CAPSULE_NAME_PYMEM, pymem_destructor);
|
pa->keep = PyCapsule_New(pa->value.p, CTYPES_CAPSULE_NAME_PYMEM, pymem_destructor);
|
||||||
|
|
|
@ -1434,7 +1434,7 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
|
||||||
PyObject *keep;
|
PyObject *keep;
|
||||||
wchar_t *buffer;
|
wchar_t *buffer;
|
||||||
|
|
||||||
buffer = PyUnicode_AsWideCharString((PyUnicodeObject *)value, NULL);
|
buffer = PyUnicode_AsWideCharString(value, NULL);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -246,10 +246,10 @@ PyLocale_strcoll(PyObject* self, PyObject* args)
|
||||||
if (!PyArg_ParseTuple(args, "UU:strcoll", &os1, &os2))
|
if (!PyArg_ParseTuple(args, "UU:strcoll", &os1, &os2))
|
||||||
return NULL;
|
return NULL;
|
||||||
/* Convert the unicode strings to wchar[]. */
|
/* Convert the unicode strings to wchar[]. */
|
||||||
ws1 = PyUnicode_AsWideCharString((PyUnicodeObject*)os1, NULL);
|
ws1 = PyUnicode_AsWideCharString(os1, NULL);
|
||||||
if (ws1 == NULL)
|
if (ws1 == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
ws2 = PyUnicode_AsWideCharString((PyUnicodeObject*)os2, NULL);
|
ws2 = PyUnicode_AsWideCharString(os2, NULL);
|
||||||
if (ws2 == NULL)
|
if (ws2 == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* Collate the strings. */
|
/* Collate the strings. */
|
||||||
|
|
|
@ -1426,7 +1426,7 @@ unicode_aswidecharstring(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "U", &unicode))
|
if (!PyArg_ParseTuple(args, "U", &unicode))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buffer = PyUnicode_AsWideCharString((PyUnicodeObject*)unicode, &size);
|
buffer = PyUnicode_AsWideCharString(unicode, &size);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -502,7 +502,7 @@ time_strftime(PyObject *self, PyObject *args)
|
||||||
buf.tm_isdst = 1;
|
buf.tm_isdst = 1;
|
||||||
|
|
||||||
#ifdef HAVE_WCSFTIME
|
#ifdef HAVE_WCSFTIME
|
||||||
format = PyUnicode_AsWideCharString((PyUnicodeObject*)format_arg, NULL);
|
format = PyUnicode_AsWideCharString(format_arg, NULL);
|
||||||
if (format == NULL)
|
if (format == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
fmt = format;
|
fmt = format;
|
||||||
|
|
|
@ -1275,7 +1275,7 @@ PyUnicode_AsWideChar(PyUnicodeObject *unicode,
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t*
|
wchar_t*
|
||||||
PyUnicode_AsWideCharString(PyUnicodeObject *unicode,
|
PyUnicode_AsWideCharString(PyObject *unicode,
|
||||||
Py_ssize_t *size)
|
Py_ssize_t *size)
|
||||||
{
|
{
|
||||||
wchar_t* buffer;
|
wchar_t* buffer;
|
||||||
|
@ -1286,7 +1286,7 @@ PyUnicode_AsWideCharString(PyUnicodeObject *unicode,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buflen = unicode_aswidechar(unicode, NULL, 0);
|
buflen = unicode_aswidechar((PyUnicodeObject *)unicode, NULL, 0);
|
||||||
if (PY_SSIZE_T_MAX / sizeof(wchar_t) < buflen) {
|
if (PY_SSIZE_T_MAX / sizeof(wchar_t) < buflen) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1297,7 +1297,7 @@ PyUnicode_AsWideCharString(PyUnicodeObject *unicode,
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
buflen = unicode_aswidechar(unicode, buffer, buflen);
|
buflen = unicode_aswidechar((PyUnicodeObject *)unicode, buffer, buflen);
|
||||||
if (size != NULL)
|
if (size != NULL)
|
||||||
*size = buflen;
|
*size = buflen;
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
@ -1970,7 +1970,7 @@ _Py_fopen(PyObject *unicode, const char *mode)
|
||||||
if (usize == 0)
|
if (usize == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path = PyUnicode_AsWideCharString((PyUnicodeObject*)unicode, NULL);
|
path = PyUnicode_AsWideCharString(unicode, NULL);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
f = _wfopen(path, wmode);
|
f = _wfopen(path, wmode);
|
||||||
|
@ -2001,7 +2001,7 @@ _Py_stat(PyObject *unicode, struct stat *statbuf)
|
||||||
int err;
|
int err;
|
||||||
struct _stat wstatbuf;
|
struct _stat wstatbuf;
|
||||||
|
|
||||||
path = PyUnicode_AsWideCharString((PyUnicodeObject*)unicode, NULL);
|
path = PyUnicode_AsWideCharString(unicode, NULL);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
err = _wstat(path, &wstatbuf);
|
err = _wstat(path, &wstatbuf);
|
||||||
|
@ -3736,7 +3736,7 @@ NullImporter_init(NullImporter *self, PyObject *args, PyObject *kwds)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = PyUnicode_AsWideCharString((PyUnicodeObject*)pathobj, NULL);
|
path = PyUnicode_AsWideCharString(pathobj, NULL);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
/* see issue1293 and issue3677:
|
/* see issue1293 and issue3677:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue