mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Merged revisions 65654 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r65654 | martin.v.loewis | 2008-08-12 16:49:50 +0200 (Tue, 12 Aug 2008) | 6 lines Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple, by denying s# to parse objects that have a releasebuffer procedure, and introducing s*. More module might need to get converted to use s*. ........
This commit is contained in:
parent
688356f59f
commit
423be95dcf
32 changed files with 721 additions and 390 deletions
|
@ -608,18 +608,24 @@ MultibyteCodec_Decode(MultibyteCodecObject *self,
|
|||
MultibyteCodec_State state;
|
||||
MultibyteDecodeBuffer buf;
|
||||
PyObject *errorcb;
|
||||
Py_buffer pdata;
|
||||
const char *data, *errors = NULL;
|
||||
Py_ssize_t datalen, finalsize;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|z:decode",
|
||||
codeckwarglist, &data, &datalen, &errors))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s*|z:decode",
|
||||
codeckwarglist, &pdata, &errors))
|
||||
return NULL;
|
||||
data = pdata.buf;
|
||||
datalen = pdata.len;
|
||||
|
||||
errorcb = internal_error_callback(errors);
|
||||
if (errorcb == NULL)
|
||||
if (errorcb == NULL) {
|
||||
PyBuffer_Release(&pdata);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (datalen == 0) {
|
||||
PyBuffer_Release(&pdata);
|
||||
ERROR_DECREF(errorcb);
|
||||
return make_tuple(PyUnicode_FromUnicode(NULL, 0), 0);
|
||||
}
|
||||
|
@ -659,11 +665,13 @@ MultibyteCodec_Decode(MultibyteCodecObject *self,
|
|||
if (PyUnicode_Resize(&buf.outobj, finalsize) == -1)
|
||||
goto errorexit;
|
||||
|
||||
PyBuffer_Release(&pdata);
|
||||
Py_XDECREF(buf.excobj);
|
||||
ERROR_DECREF(errorcb);
|
||||
return make_tuple(buf.outobj, datalen);
|
||||
|
||||
errorexit:
|
||||
PyBuffer_Release(&pdata);
|
||||
ERROR_DECREF(errorcb);
|
||||
Py_XDECREF(buf.excobj);
|
||||
Py_XDECREF(buf.outobj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue