From 91a639a094978882caef91915c932fbb2fc347de Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Mon, 22 Feb 2021 22:11:48 +0900 Subject: bpo-36346: Emit DeprecationWarning for PyArg_Parse() with 'u' or 'Z'. (GH-20927) Emit DeprecationWarning when PyArg_Parse*() is called with 'u', 'Z' format. See PEP 623. --- Python/getargs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Python/getargs.c') diff --git a/Python/getargs.c b/Python/getargs.c index 8839492e5e..936eb6a89a 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -1014,7 +1014,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, case 'u': /* raw unicode buffer (Py_UNICODE *) */ case 'Z': /* raw unicode buffer or None */ { - // TODO: Raise DeprecationWarning + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "getargs: The '%c' format is deprecated. Use 'U' instead.", c)) { + return NULL; + } _Py_COMP_DIAG_PUSH _Py_COMP_DIAG_IGNORE_DEPR_DECLS Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **); -- cgit v1.2.1