summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2021-02-22 13:11:48 (GMT)
committerGitHub <noreply@github.com>2021-02-22 13:11:48 (GMT)
commit91a639a094978882caef91915c932fbb2fc347de (patch)
tree29ee9246d022b40a529c881e8deb0d6503b4d993 /Python
parent5a4aa4c03e27ca5007b86c9c1ee62c77ad08a120 (diff)
downloadcpython-91a639a094978882caef91915c932fbb2fc347de.zip
cpython-91a639a094978882caef91915c932fbb2fc347de.tar.gz
cpython-91a639a094978882caef91915c932fbb2fc347de.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/getargs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 8839492..936eb6a 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 **);