diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-10-11 14:40:37 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-10-11 14:40:37 (GMT) |
commit | 4819e97a48e3e6584035c482d24953018bf2f851 (patch) | |
tree | 5e124421b7b40bdeaeb4cbd62ff52ea583ffe58e /Python/getargs.c | |
parent | de7c1923c72d4fca565925e6cc82f3951d42b1d1 (diff) | |
download | cpython-4819e97a48e3e6584035c482d24953018bf2f851.zip cpython-4819e97a48e3e6584035c482d24953018bf2f851.tar.gz cpython-4819e97a48e3e6584035c482d24953018bf2f851.tar.bz2 |
Undo part of 2.59: 't' case of convertsimple() should not use convertbuffer().
convertbuffer() uses the buffer interface's getreadbuffer(), but 't'
should use getcharbuffer().
Diffstat (limited to 'Python/getargs.c')
-rw-r--r-- | Python/getargs.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 089aaea..0acb23a 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -635,7 +635,6 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf) else { /* any buffer-like object */ char *buf; int count = convertbuffer(arg, p, &buf); - if (count < 0) return converterr(buf, arg, msgbuf); *q = count; @@ -936,7 +935,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf) case 't': { /* 8-bit character buffer, read-only access */ const char **p = va_arg(*p_va, const char **); - char *buf; + PyBufferProcs *pb = arg->ob_type->tp_as_buffer; int count; if (*format++ != '#') @@ -944,14 +943,21 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf) "invalid use of 't' format character", arg, msgbuf); if (!PyType_HasFeature(arg->ob_type, - Py_TPFLAGS_HAVE_GETCHARBUFFER)) + Py_TPFLAGS_HAVE_GETCHARBUFFER) || + pb == NULL || pb->bf_getcharbuffer == NULL || + pb->bf_getsegcount == NULL) return converterr( "string or read-only character buffer", arg, msgbuf); - count = convertbuffer(arg, (void **)p, &buf); + if (pb->bf_getsegcount(arg, NULL) != 1) + return converterr( + "string or single-segment read-only buffer", + arg, msgbuf); + + count = pb->bf_getcharbuffer(arg, 0, p); if (count < 0) - return converterr(buf, arg, msgbuf); + return converterr("(unspecified)", arg, msgbuf); *va_arg(*p_va, int *) = count; break; } |