Make read() and certificate() return bytes instead of bytearray instances.
This commit is contained in:
parent
254348e201
commit
f06628b072
@ -977,7 +977,7 @@ PySSL_peercert(PySSLObject *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
/* this is actually an immutable bytes sequence */
|
||||
retval = PyBytes_FromStringAndSize
|
||||
retval = PyString_FromStringAndSize
|
||||
((const char *) bytes_buf, len);
|
||||
OPENSSL_free(bytes_buf);
|
||||
return retval;
|
||||
@ -1281,13 +1281,8 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
|
||||
Py_DECREF(buf);
|
||||
return NULL;
|
||||
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
|
||||
/* should contain a zero-length string */
|
||||
if (!buf_passed) {
|
||||
PyBytes_Resize(buf, 0);
|
||||
return buf;
|
||||
} else {
|
||||
return PyInt_FromLong(0);
|
||||
}
|
||||
count = 0;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
do {
|
||||
@ -1312,12 +1307,8 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
|
||||
(SSL_get_shutdown(self->ssl) ==
|
||||
SSL_RECEIVED_SHUTDOWN))
|
||||
{
|
||||
if (!buf_passed) {
|
||||
PyBytes_Resize(buf, 0);
|
||||
return buf;
|
||||
} else {
|
||||
return PyInt_FromLong(0);
|
||||
}
|
||||
count = 0;
|
||||
goto done;
|
||||
} else {
|
||||
sockstate = SOCKET_OPERATION_OK;
|
||||
}
|
||||
@ -1338,11 +1329,12 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
|
||||
}
|
||||
return PySSL_SetError(self, count, __FILE__, __LINE__);
|
||||
}
|
||||
done:
|
||||
if (!buf_passed) {
|
||||
if (count != len) {
|
||||
PyBytes_Resize(buf, count);
|
||||
}
|
||||
return buf;
|
||||
PyObject *res = PyString_FromStringAndSize(
|
||||
PyBytes_AS_STRING(buf), count);
|
||||
Py_DECREF(buf);
|
||||
return res;
|
||||
} else {
|
||||
return PyInt_FromLong(count);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user