mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Add PyUnicode_AsStringAndSize(), which is like PyUnicode_AsString() but
has an extra (optional) output parameter through which it returns the size. Use this in a few places where I used PyUnicode_AsString() + strlen(), and in one new place (which fixes test_pep263).
This commit is contained in:
parent
9befa93b04
commit
7d1df6c9b1
4 changed files with 31 additions and 17 deletions
|
@ -383,7 +383,8 @@ fp_readl(char *s, int size, struct tok_state *tok)
|
|||
goto error;
|
||||
allocated = 1;
|
||||
}
|
||||
if (PyObject_AsCharBuffer(bufobj, &buf, &buflen) < 0) {
|
||||
buf = PyUnicode_AsStringAndSize(bufobj, &buflen);
|
||||
if (buf == NULL) {
|
||||
goto error;
|
||||
}
|
||||
if (buflen > size) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue