From 59799a83995f135bdb1b1a0994052c1f24c68e83 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 13 Nov 2013 14:17:30 +0100 Subject: Don't use deprecated function PyUnicode_GET_SIZE() Replace it with PyUnicode_GET_LENGTH() or PyUnicode_AsUnicodeAndSize() --- Modules/_elementtree.c | 2 +- Modules/posixmodule.c | 11 +++++------ Objects/namespaceobject.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index cb7069d..797e357 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -3461,7 +3461,7 @@ xmlparser_parse_whole(XMLParserObject* self, PyObject* args) if (PyUnicode_CheckExact(buffer)) { /* A unicode object is encoded into bytes using UTF-8 */ - if (PyUnicode_GET_SIZE(buffer) == 0) { + if (PyUnicode_GET_LENGTH(buffer) == 0) { Py_DECREF(buffer); break; } diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index f282f99..5e5f355 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -829,15 +829,14 @@ path_converter(PyObject *o, void *p) { if (unicode) { #ifdef MS_WINDOWS wchar_t *wide; - length = PyUnicode_GET_SIZE(unicode); - if (length > 32767) { - FORMAT_EXCEPTION(PyExc_ValueError, "%s too long for Windows"); + + wide = PyUnicode_AsUnicodeAndSize(unicode, &length); + if (!wide) { Py_DECREF(unicode); return 0; } - - wide = PyUnicode_AsUnicode(unicode); - if (!wide) { + if (length > 32767) { + FORMAT_EXCEPTION(PyExc_ValueError, "%s too long for Windows"); Py_DECREF(unicode); return 0; } diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c index 9e95094..720ac0d 100644 --- a/Objects/namespaceobject.c +++ b/Objects/namespaceobject.c @@ -101,7 +101,7 @@ namespace_repr(PyObject *ns) goto error; while ((key = PyIter_Next(keys_iter)) != NULL) { - if (PyUnicode_Check(key) && PyUnicode_GET_SIZE(key) > 0) { + if (PyUnicode_Check(key) && PyUnicode_GET_LENGTH(key) > 0) { PyObject *value, *item; value = PyDict_GetItem(d, key); -- cgit v0.12