Commit 60a1e7fc authored by Guido van Rossum's avatar Guido van Rossum

Clarified some of the error messages, esp. "read-only character

buffer" replaced by "string or read-only character buffer".
parent 9940b800
......@@ -565,7 +565,7 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
arg = _PyUnicode_AsDefaultEncodedString(
arg, NULL);
if (arg == NULL)
return "unicode conversion error";
return "(unicode conversion error)";
*p = PyString_AS_STRING(arg);
*q = PyString_GET_SIZE(arg);
}
......@@ -575,9 +575,9 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
if ( pb == NULL ||
pb->bf_getreadbuffer == NULL ||
pb->bf_getsegcount == NULL )
return "read-only buffer";
return "string or read-only buffer";
if ( (*pb->bf_getsegcount)(arg, NULL) != 1 )
return "single-segment read-only buffer";
return "string or single-segment read-only buffer";
if ( (count =
(*pb->bf_getreadbuffer)(arg, 0, p)) < 0 )
return "(unspecified)";
......@@ -593,7 +593,7 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
arg = _PyUnicode_AsDefaultEncodedString(
arg, NULL);
if (arg == NULL)
return "unicode conversion error";
return "(unicode conversion error)";
*p = PyString_AS_STRING(arg);
}
else
......@@ -622,7 +622,7 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
arg = _PyUnicode_AsDefaultEncodedString(
arg, NULL);
if (arg == NULL)
return "unicode conversion error";
return "(unicode conversion error)";
*p = PyString_AS_STRING(arg);
*q = PyString_GET_SIZE(arg);
}
......@@ -632,9 +632,9 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
if ( pb == NULL ||
pb->bf_getreadbuffer == NULL ||
pb->bf_getsegcount == NULL )
return "read-only buffer";
return "string or read-only buffer";
if ( (*pb->bf_getsegcount)(arg, NULL) != 1 )
return "single-segment read-only buffer";
return "string or single-segment read-only buffer";
if ( (count =
(*pb->bf_getreadbuffer)(arg, 0, p)) < 0 )
return "(unspecified)";
......@@ -652,11 +652,11 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
arg = _PyUnicode_AsDefaultEncodedString(
arg, NULL);
if (arg == NULL)
return "unicode conversion error";
return "(unicode conversion error)";
*p = PyString_AS_STRING(arg);
}
else
return "None or string";
return "string or None";
if (*format == '#') {
int *q = va_arg(*p_va, int *);
if (arg == Py_None)
......@@ -667,7 +667,7 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
}
else if (*p != NULL &&
(int)strlen(*p) != PyString_Size(arg))
return "None or string without null bytes";
return "string without null bytes or None";
}
break;
}
......@@ -695,7 +695,7 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
/* Convert object to Unicode */
u = PyUnicode_FromObject(arg);
if (u == NULL)
return "string, unicode or text buffer";
return "string or unicode or text buffer";
/* Encode object; use default error handling */
s = PyUnicode_AsEncodedString(u,
......@@ -773,8 +773,7 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
*/
if ((int)strlen(PyString_AS_STRING(s)) != size)
return "(encoded string without "\
"NULL bytes)";
return "(encoded string without NULL bytes)";
*buffer = PyMem_NEW(char, size + 1);
if (*buffer == NULL) {
Py_DECREF(s);
......@@ -799,9 +798,9 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
if ( pb == NULL ||
pb->bf_getreadbuffer == NULL ||
pb->bf_getsegcount == NULL )
return "read-only buffer";
return "unicode or read-only buffer";
if ( (*pb->bf_getsegcount)(arg, NULL) != 1 )
return "single-segment read-only buffer";
return "unicode or single-segment read-only buffer";
if ( (count =
(*pb->bf_getreadbuffer)(arg, 0, p)) < 0 )
return "(unspecified)";
......@@ -916,9 +915,9 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
pb == NULL ||
pb->bf_getcharbuffer == NULL ||
pb->bf_getsegcount == NULL )
return "read-only character buffer";
return "string or read-only character buffer";
if ( (*pb->bf_getsegcount)(arg, NULL) != 1 )
return "single-segment read-only buffer";
return "string or single-segment read-only buffer";
if ( (count = pb->bf_getcharbuffer(arg, 0, p)) < 0 )
return "(unspecified)";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment