aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2011-01-04 18:32:24 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:48:07 -0300
commitf7fd9277f47359f8eb4490bcb8f5bdc84000035e (patch)
tree2d1e184a67de6463b79f67b54b2a119234bc4aae
parent4351b2e5133e89c02ff26ecbf0f7df6e902efc64 (diff)
Fixed function QDataStream.readRawData return value.
The function readRawData now return None in case of error, otherwise a string with the read data. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
-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 df04ca9c8..54513f951 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 7ccc12e56..ad7445700 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()