Bug 386610 - "pyxpcom fails to build against python 2.5 (api changed)" [p=asac@jwsdot.com (Alexander Sack) r=mhammond (NPOTB)]
git-svn-id: svn://10.0.0.236/trunk@242424 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -65,12 +65,19 @@ static PyObject *DoPyRead_Buffer(nsIInputStream *pI, PyObject *obBuffer, PRUint3
|
||||
{
|
||||
PRUint32 nread;
|
||||
void *buf;
|
||||
PRUint32 buf_len;
|
||||
if (PyObject_AsWriteBuffer(obBuffer, &buf, (int *)&buf_len) != 0) {
|
||||
Py_ssize_t buf_len;
|
||||
if (PyObject_AsWriteBuffer(obBuffer, &buf, &buf_len) != 0) {
|
||||
PyErr_Clear();
|
||||
PyErr_SetString(PyExc_TypeError, "The buffer object does not have a write buffer!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( (buf_len & 0xFFFFFFFF) != buf_len) {
|
||||
PyErr_Clear();
|
||||
PyErr_SetString(PyExc_RuntimeError, "Python Buffer length overflows 32-bit in PyObject_AsWriteBuffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (n==(PRUint32)-1) {
|
||||
n = buf_len;
|
||||
} else {
|
||||
@@ -116,11 +123,17 @@ static PyObject *DoPyRead_Size(nsIInputStream *pI, PRUint32 n)
|
||||
rc = PyBuffer_New(nread);
|
||||
if (rc != NULL) {
|
||||
void *ob_buf;
|
||||
PRUint32 buf_len;
|
||||
if (PyObject_AsWriteBuffer(rc, &ob_buf, (int *)&buf_len) != 0) {
|
||||
Py_ssize_t buf_len;
|
||||
if (PyObject_AsWriteBuffer(rc, &ob_buf, &buf_len) != 0) {
|
||||
// should never fail - we just created it!
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( (buf_len & 0xFFFFFFFF) != buf_len) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Python Buffer length overflows 32-bit in PyObject_AsWriteBuffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (buf_len != nread) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "New buffer isn't the size we created it!");
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user