diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-20 10:16:46 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-20 10:16:46 (GMT) |
commit | 460bd0d284caa00eb8ccc9a28836ba30765a19cb (patch) | |
tree | 41169cfce0d00587f4222d3237a608b70577adfc /Python | |
parent | 6107f46bfbe4aa7b2ddb37ca5136d1d472c3f4aa (diff) | |
download | cpython-460bd0d284caa00eb8ccc9a28836ba30765a19cb.zip cpython-460bd0d284caa00eb8ccc9a28836ba30765a19cb.tar.gz cpython-460bd0d284caa00eb8ccc9a28836ba30765a19cb.tar.bz2 |
Issue #19569: Compiler warnings are now emitted if use most of deprecated
functions.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/errors.c | 12 | ||||
-rw-r--r-- | Python/getargs.c | 13 | ||||
-rw-r--r-- | Python/modsupport.c | 4 |
3 files changed, 14 insertions, 15 deletions
diff --git a/Python/errors.c b/Python/errors.c index 1463cdc..01304d2 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -582,9 +582,7 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, const char *filename) PyObject * PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, const Py_UNICODE *filename) { - PyObject *name = filename ? - PyUnicode_FromUnicode(filename, wcslen(filename)) : - NULL; + PyObject *name = filename ? PyUnicode_FromWideChar(filename, -1) : NULL; PyObject *result = PyErr_SetFromErrnoWithFilenameObjects(exc, name, NULL); Py_XDECREF(name); return result; @@ -691,9 +689,7 @@ PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilename( int ierr, const Py_UNICODE *filename) { - PyObject *name = filename ? - PyUnicode_FromUnicode(filename, wcslen(filename)) : - NULL; + PyObject *name = filename ? PyUnicode_FromWideChar(filename, -1) : NULL; PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObjects(exc, ierr, name, @@ -729,9 +725,7 @@ PyObject *PyErr_SetFromWindowsErrWithUnicodeFilename( int ierr, const Py_UNICODE *filename) { - PyObject *name = filename ? - PyUnicode_FromUnicode(filename, wcslen(filename)) : - NULL; + PyObject *name = filename ? PyUnicode_FromWideChar(filename, -1) : NULL; PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObjects( PyExc_OSError, ierr, name, NULL); diff --git a/Python/getargs.c b/Python/getargs.c index a6636f4..c552d0f 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -1027,7 +1027,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, *p = PyUnicode_AsUnicodeAndSize(arg, &len); if (*p == NULL) RETURN_ERR_OCCURRED; - if (Py_UNICODE_strlen(*p) != (size_t)len) { + if (wcslen(*p) != (size_t)len) { PyErr_SetString(PyExc_ValueError, "embedded null character"); RETURN_ERR_OCCURRED; } @@ -1074,9 +1074,14 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, (PyBytes_Check(arg) || PyByteArray_Check(arg))) { s = arg; Py_INCREF(s); - if (PyObject_AsCharBuffer(s, &ptr, &size) < 0) - return converterr("(AsCharBuffer failed)", - arg, msgbuf, bufsize); + if (PyBytes_Check(arg)) { + size = PyBytes_GET_SIZE(s); + ptr = PyBytes_AS_STRING(s); + } + else { + size = PyByteArray_GET_SIZE(s); + ptr = PyByteArray_AS_STRING(s); + } } else if (PyUnicode_Check(arg)) { /* Encode object; use default error handling */ diff --git a/Python/modsupport.c b/Python/modsupport.c index aabee8f..35b529b 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -286,8 +286,8 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags) } else { if (n < 0) - n = Py_UNICODE_strlen(u); - v = PyUnicode_FromUnicode(u, n); + n = wcslen(u); + v = PyUnicode_FromWideChar(u, n); } return v; } |