Skip to content

Commit 8352afa

Browse files
committed
bpo-36346: Raise DeprecationWarning in deprecated usages.
Raise DeprecationWarning when: * PyArg_ParseTuple with 'u', 'Z' format. * PyUnicode_FromStringAndSize(NULL, size) We can not use C level deprecation because these API will be not removed.
1 parent 2165cea commit 8352afa

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``PyArg_Parse*()`` functions now emits ``DeprecationWarning`` when ``u`` or
2+
``Z`` format is used.

Python/getargs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
10141014
case 'u': /* raw unicode buffer (Py_UNICODE *) */
10151015
case 'Z': /* raw unicode buffer or None */
10161016
{
1017-
// TODO: Raise DeprecationWarning
1017+
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
1018+
"getargs: The '%c' format is deprecated. Use 'U' instead.", c)) {
1019+
return NULL;
1020+
}
10181021
_Py_COMP_DIAG_PUSH
10191022
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
10201023
Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);

0 commit comments

Comments
 (0)