summaryrefslogtreecommitdiff
path: root/Python/getargs.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 2c2db36193..77f27bebc9 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -961,8 +961,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
arg, msgbuf, bufsize);
if (*p != NULL && sarg != NULL && (Py_ssize_t) strlen(*p) != len)
return converterr(
- c == 'z' ? "str without null bytes or None"
- : "str without null bytes",
+ c == 'z' ? "str without null characters or None"
+ : "str without null characters",
arg, msgbuf, bufsize);
}
break;
@@ -982,10 +982,11 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
STORE_SIZE(0);
}
else if (PyUnicode_Check(arg)) {
- *p = PyUnicode_AS_UNICODE(arg);
+ Py_ssize_t len;
+ *p = PyUnicode_AsUnicodeAndSize(arg, &len);
if (*p == NULL)
RETURN_ERR_OCCURRED;
- STORE_SIZE(PyUnicode_GET_SIZE(arg));
+ STORE_SIZE(len);
}
else
return converterr("str or None", arg, msgbuf, bufsize);
@@ -995,12 +996,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
if (c == 'Z' && arg == Py_None)
*p = NULL;
else if (PyUnicode_Check(arg)) {
- *p = PyUnicode_AS_UNICODE(arg);
+ Py_ssize_t len;
+ *p = PyUnicode_AsUnicodeAndSize(arg, &len);
if (*p == NULL)
RETURN_ERR_OCCURRED;
- if (Py_UNICODE_strlen(*p) != PyUnicode_GET_SIZE(arg))
+ if (Py_UNICODE_strlen(*p) != len)
return converterr(
- "str without null character or None",
+ "str without null characters or None",
arg, msgbuf, bufsize);
} else
return converterr(c == 'Z' ? "str or None" : "str",