Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5216e6d

Browse files
author
Victor Stinner
committed
PyArg_Parse*("Z#") raises an error for unknown type
instead of ignoring the error and leave the pointer to the string and the size unchanged (not initialized). Fix also the type in the error message of "Z", "Z#" and "Y" formats.
1 parent 55a5c78 commit 5216e6d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Python/getargs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
10511051
*p = PyUnicode_AS_UNICODE(arg);
10521052
STORE_SIZE(PyUnicode_GET_SIZE(arg));
10531053
}
1054+
else
1055+
return converterr("str or None", arg, msgbuf, bufsize);
10541056
format++;
10551057
} else {
10561058
Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);
@@ -1060,8 +1062,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
10601062
else if (PyUnicode_Check(arg))
10611063
*p = PyUnicode_AS_UNICODE(arg);
10621064
else
1063-
return converterr("string or None",
1064-
arg, msgbuf, bufsize);
1065+
return converterr("str or None", arg, msgbuf, bufsize);
10651066
}
10661067
break;
10671068
}
@@ -1258,7 +1259,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
12581259
if (PyByteArray_Check(arg))
12591260
*p = arg;
12601261
else
1261-
return converterr("buffer", arg, msgbuf, bufsize);
1262+
return converterr("bytearray", arg, msgbuf, bufsize);
12621263
break;
12631264
}
12641265

0 commit comments

Comments
 (0)