summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-29 13:53:23 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-29 13:53:23 (GMT)
commit7d1df6c9b1a7e075c03c4790f47bc83e0104579f (patch)
tree6dceba59593ca682c88dd1a699fec2fc51f78129 /Parser
parent9befa93b04ee0c485615d87e4b34dcfe5e811194 (diff)
downloadcpython-7d1df6c9b1a7e075c03c4790f47bc83e0104579f.zip
cpython-7d1df6c9b1a7e075c03c4790f47bc83e0104579f.tar.gz
cpython-7d1df6c9b1a7e075c03c4790f47bc83e0104579f.tar.bz2
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).
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 8f30fef..6320f75 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -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) {