diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2007-10-14 02:05:51 +0000 |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2007-10-14 02:05:51 +0000 |
commit | 70a237179f1213b0c180898b6e1f0b6c4e9cd11c (patch) | |
tree | a0d454e61877a808e682ab90d2cc268d4ce5f23c /Modules/_sre.c | |
parent | 659e7f44e2f0bc92db8b4e33fb6bae429dcbd205 (diff) | |
download | cpython-git-70a237179f1213b0c180898b6e1f0b6c4e9cd11c.tar.gz |
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.
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r-- | Modules/_sre.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c index 18686577e4..f4cd1feffa 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -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; |