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:
Serhiy Storchaka 2014-09-06 20:07:17 +03:00
parent 4a4b679515
commit d8a1447c99
14 changed files with 41 additions and 39 deletions

View file

@ -593,8 +593,8 @@ PyBytes_AsStringAndSize(PyObject *obj,
if (len != NULL)
*len = PyBytes_GET_SIZE(obj);
else if (strlen(*s) != (size_t)PyBytes_GET_SIZE(obj)) {
PyErr_SetString(PyExc_TypeError,
"expected bytes with no null");
PyErr_SetString(PyExc_ValueError,
"embedded null byte");
return -1;
}
return 0;