Changeset 86333 in vbox for trunk/src/libs/xpcom18a4/python/src/PyGInputStream.cpp
- Timestamp:
- Sep 28, 2020 8:01:18 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 140619
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/python/src/PyGInputStream.cpp
r11746 r86333 104 104 nsresult nr = InvokeNativeViaPolicy(methodName, &ret, "i", count); 105 105 if (NS_SUCCEEDED(nr)) { 106 #ifndef VBOX /* unsafe cast on 64-bit hosts. */ 106 #if 0 /* VBox: new buffer protocol (though I could use it for Py_LIMITED_API and ditch the warning, but cpython specific) */ 107 Py_buffer py_view; 108 if (PyObject_GetBuffer(ret, &py_view, PyBUF_SIMPLE) == 0) { 109 if (py_view.len <= count) { 110 count = py_view.len; 111 } else { 112 PyXPCOM_LogWarning("nsIInputStream::read() was asked for %d bytes, but the string returned is %d bytes - truncating!\n", count, py_size); 113 } 114 memcpy(buf, py_view.py_buf, count); 115 PyBuffer_Release(&py_view); 116 *_retval = count; 117 } else { 118 PyErr_Format(PyExc_TypeError, "nsIInputStream::read() method must return a buffer object - not a '%s' object", PyXPCOM_ObTypeName(ret)); 119 nr = HandleNativeGatewayError(methodName); 120 } 121 #else /* Old protocol: */ 122 # ifndef VBOX /* unsafe cast on 64-bit hosts. */ 107 123 PRUint32 py_size; 108 124 const void *py_buf; 109 125 if (PyObject_AsReadBuffer(ret, &py_buf, (Py_ssize_t*)&py_size)!=0) { 110 # else /* VBOX */126 # else /* VBOX */ 111 127 const void *py_buf; 112 # if PY_VERSION_HEX >= 0x02050000 || defined(PY_SSIZE_T_MIN)128 # if PY_VERSION_HEX >= 0x02050000 || defined(PY_SSIZE_T_MIN) 113 129 Py_ssize_t py_size; 114 # else130 # else 115 131 int py_size; 132 # endif 133 if (PyObject_AsReadBuffer(ret, &py_buf, &py_size)!=0) { 116 134 # endif /* VBOX */ 117 if (PyObject_AsReadBuffer(ret, &py_buf, &py_size)!=0) { 118 #endif /* VBOX */ 119 PyErr_Format(PyExc_TypeError, "nsIInputStream::read() method must return a buffer object - not a '%s' object", ret->ob_type->tp_name); 135 PyErr_Format(PyExc_TypeError, "nsIInputStream::read() method must return a buffer object - not a '%s' object", PyXPCOM_ObTypeName(ret)); 120 136 nr = HandleNativeGatewayError(methodName); 121 137 } else { … … 127 143 *_retval = py_size; 128 144 } 145 #endif 129 146 } 130 147 return nr;
Note:
See TracChangeset
for help on using the changeset viewer.