Issue #23001: Few functions in modules mmap, ossaudiodev, socket, ssl, and

codecs, that accepted only read-only bytes-like object now accept writable
bytes-like object too.
This commit is contained in:
Serhiy Storchaka 2015-03-20 09:00:36 +02:00
parent 0eac13052c
commit 8490f5acfe
14 changed files with 196 additions and 104 deletions

View file

@ -3672,18 +3672,22 @@ static PyTypeObject PySSLMemoryBIO_Type = {
static PyObject *
PySSL_RAND_add(PyObject *self, PyObject *args)
{
char *buf;
Py_buffer view;
const char *buf;
Py_ssize_t len, written;
double entropy;
if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy))
if (!PyArg_ParseTuple(args, "s*d:RAND_add", &view, &entropy))
return NULL;
buf = (const char *)view.buf;
len = view.len;
do {
written = Py_MIN(len, INT_MAX);
RAND_add(buf, (int)written, entropy);
buf += written;
len -= written;
} while (len);
PyBuffer_Release(&view);
Py_INCREF(Py_None);
return Py_None;
}