summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PySide/QtCore/typesystem_core.xml9
-rw-r--r--tests/QtCore/qdatastream_test.py8
2 files changed, 11 insertions, 6 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index df04ca9..54513f9 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -2388,8 +2388,13 @@
<inject-code class="target">
QByteArray data;
data.resize(%2);
- %CPPSELF.%FUNCTION_NAME(data.data(), data.size());
- %PYARG_0 = PyString_FromStringAndSize(data.constData(), data.size());
+ int result = %CPPSELF.%FUNCTION_NAME(data.data(), data.size());
+ if (result == -1) {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+ } else {
+ %PYARG_0 = PyString_FromStringAndSize(data.data(), result);
+ }
</inject-code>
</modify-function>
<!-- deprecated method -->
diff --git a/tests/QtCore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py
index 7ccc12e..ad74457 100644
--- a/tests/QtCore/qdatastream_test.py
+++ b/tests/QtCore/qdatastream_test.py
@@ -311,15 +311,15 @@ class QDataStreamShiftBitArray(unittest.TestCase):
class QDataStreamRawData(unittest.TestCase):
def testRawData(self):
data = QDataStream()
- self.assertEqual(data.readRawData(4), '\x00\x00\x00\x00')
+ self.assertEqual(data.readRawData(4), None)
ba = QByteArray()
data = QDataStream(ba, QIODevice.WriteOnly)
- data.writeRawData('ABC')
- self.assertEqual(ba, 'ABC')
+ data.writeRawData('AB\x00C')
+ self.assertEqual(ba.data(), 'AB\x00C')
data = QDataStream(ba)
- self.assertEqual(data.readRawData(4), 'ABC\x00')
+ self.assertEqual(data.readRawData(4), 'AB\x00C')
if __name__ == '__main__':
unittest.main()