bpo-34984: Improve error messages for bytes and bytearray constructors. (GH-9874)

This commit is contained in:
Serhiy Storchaka 2018-10-21 15:29:12 +03:00 committed by GitHub
parent 914f9a078f
commit 2c2044e789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 6 deletions

View file

@ -2537,8 +2537,9 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (x == NULL) {
if (encoding != NULL || errors != NULL) {
PyErr_SetString(PyExc_TypeError,
"encoding or errors without sequence "
"argument");
encoding != NULL ?
"encoding without a string argument" :
"errors without a string argument");
return NULL;
}
return PyBytes_FromStringAndSize(NULL, 0);