Remove the buffer API from PyUnicode as specified by PEP 3137. Also,

fix the error message of the 't' format unit, in getargs.c, so that it
asks for bytes, instead of string.
This commit is contained in:
Alexandre Vassalotti 2007-10-14 02:05:51 +00:00
parent 659e7f44e2
commit 70a237179f
4 changed files with 13 additions and 17 deletions

View file

@ -1674,6 +1674,15 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize)
void* ptr;
Py_buffer view;
/* Unicode objects do not support the buffer API. So, get the data
directly instead. */
if (PyUnicode_Check(string)) {
ptr = (void *)PyUnicode_AS_DATA(string);
*p_length = PyUnicode_GET_SIZE(string);
*p_charsize = sizeof(Py_UNICODE);
return ptr;
}
/* get pointer to string buffer */
view.len = -1;
buffer = Py_Type(string)->tp_as_buffer;