Fix 666 - "QByteArray does not support slices"
Reviewer: Renato Araújo <renato.filho@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
59c882566b
commit
44998fd471
2 changed files with 20 additions and 0 deletions
|
|
@ -1811,6 +1811,17 @@
|
||||||
return !result ? -1 : 0;
|
return !result ? -1 : 0;
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</add-function>
|
</add-function>
|
||||||
|
<add-function signature="__getslice__">
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
Py_ssize_t max = %CPPSELF.count();
|
||||||
|
_i1 = qBound(Py_ssize_t(0), _i1, max);
|
||||||
|
_i2 = qBound(Py_ssize_t(0), _i2, max);
|
||||||
|
|
||||||
|
if (_i1 >= _i2)
|
||||||
|
return %CONVERTTOPYTHON[QByteArray](QByteArray());
|
||||||
|
return %CONVERTTOPYTHON[QByteArray](%CPPSELF.mid(_i1, _i2 - _i1));
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
</value-type>
|
</value-type>
|
||||||
<value-type name="QTextBoundaryFinder">
|
<value-type name="QTextBoundaryFinder">
|
||||||
<enum-type name="BoundaryReason" flags="QTextBoundaryFinder::BoundaryReasons"/>
|
<enum-type name="BoundaryReason" flags="QTextBoundaryFinder::BoundaryReasons"/>
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,15 @@ class QByteArrayOnQVariant(unittest.TestCase):
|
||||||
a = QSettings().value("some_prop", QByteArray())
|
a = QSettings().value("some_prop", QByteArray())
|
||||||
self.assertEqual(type(a), QByteArray)
|
self.assertEqual(type(a), QByteArray)
|
||||||
|
|
||||||
|
class TestBug666(unittest.TestCase):
|
||||||
|
'''QByteArray does not support slices'''
|
||||||
|
def testIt(self):
|
||||||
|
ba = QByteArray('1234567890')
|
||||||
|
self.assertEqual(ba[2:4], '34')
|
||||||
|
self.assertEqual(ba[:4], '1234')
|
||||||
|
self.assertEqual(ba[4:], '567890')
|
||||||
|
self.assertEqual(len(ba[4:1]), 0)
|
||||||
|
|
||||||
class QByteArrayBug514(unittest.TestCase):
|
class QByteArrayBug514(unittest.TestCase):
|
||||||
def testIt(self):
|
def testIt(self):
|
||||||
data = "foobar"
|
data = "foobar"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue