summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-07-21 16:25:22 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-07-21 16:25:22 -0300
commit239ae999fa0d07893e5e29f611d1919374853b2f (patch)
treec39b8b71700c653f30f62e18ded26b4f36d16134
parentb2ec5cf60752e2ce8f9950fde809d841ad8e6793 (diff)
downloadpyside-239ae999fa0d07893e5e29f611d1919374853b2f.tar.gz
pyside-239ae999fa0d07893e5e29f611d1919374853b2f.tar.xz
pyside-239ae999fa0d07893e5e29f611d1919374853b2f.zip
Fix bug 934 - "A __getitem__ of QByteArray behaves strange"
-rw-r--r--PySide/QtCore/typesystem_core.xml2
-rw-r--r--tests/QtCore/qbytearray_operator_test.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 8421e9a..2ed071e 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -1893,7 +1893,7 @@
char res[2];
res[0] = %CPPSELF.at(_i);
res[1] = 0;
- return PyString_FromString(res);
+ return PyString_FromStringAndSize(res, 1);
}
</inject-code>
</add-function>
diff --git a/tests/QtCore/qbytearray_operator_test.py b/tests/QtCore/qbytearray_operator_test.py
index 662bc6e..50bb5f7 100644
--- a/tests/QtCore/qbytearray_operator_test.py
+++ b/tests/QtCore/qbytearray_operator_test.py
@@ -56,6 +56,10 @@ class QByteArrayOperatorAt(unittest.TestCase):
obj = QByteArray(string)
self.assertRaises(IndexError, lambda :obj[len(string)])
+ def testNullStrings(self):
+ ba = QByteArray('\x00')
+ self.assertEqual(ba.at(0), '\x00')
+ self.assertEqual(ba[0], '\x00')
class QByteArrayOperatorLen(unittest.TestCase):
'''Test case for __len__ operator of QByteArray'''