mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #22215: Now ValueError is raised instead of TypeError when str or bytes
argument contains not permitted null character or byte.
This commit is contained in:
parent
4a4b679515
commit
d8a1447c99
14 changed files with 41 additions and 39 deletions
|
@ -1417,7 +1417,7 @@ varname_converter(PyObject *in, void *_out)
|
|||
}
|
||||
s = PyBytes_AsString(in);
|
||||
if (strlen(s) != (size_t)PyBytes_Size(in)) {
|
||||
PyErr_SetString(PyExc_ValueError, "null byte in bytes object");
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null byte");
|
||||
return 0;
|
||||
}
|
||||
*out = s;
|
||||
|
@ -1434,7 +1434,7 @@ varname_converter(PyObject *in, void *_out)
|
|||
return 0;
|
||||
}
|
||||
if (strlen(s) != (size_t)size) {
|
||||
PyErr_SetString(PyExc_ValueError, "null character in string");
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
return 0;
|
||||
}
|
||||
*out = s;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue