We do not support character buffer protocol on QStrings.
The only way of supporting it is storing an 8-bit encoded version of QString into the QString instance, this will increase the memory usage of QString in 50%, and we don't want it. So, if you need to pass QStrings for a python functions which doesn't accept unicode, just cast yourself the QString to a python string.
This commit is contained in:
parent
a50ecea26d
commit
1a7cbb2473
1 changed files with 0 additions and 25 deletions
|
|
@ -1,25 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
'''Tests QString implementation of Python buffer protocol'''
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from os.path import isdir
|
|
||||||
from PySide.QtCore import QString
|
|
||||||
|
|
||||||
class QStringBufferProtocolTest(unittest.TestCase):
|
|
||||||
'''Tests QString implementation of Python buffer protocol'''
|
|
||||||
|
|
||||||
def testQStringBufferProtocol(self):
|
|
||||||
#Tests QString implementation of Python buffer protocol using the os.path.isdir
|
|
||||||
#function which an unicode object or other object implementing the Python buffer protocol
|
|
||||||
os_path_isdir_function_correctly_called_with_a_qstring = True
|
|
||||||
try:
|
|
||||||
isdir(QString('/tmp'))
|
|
||||||
except:
|
|
||||||
os_path_isdir_function_correctly_called_with_a_qstring = False
|
|
||||||
self.assertTrue(os_path_isdir_function_correctly_called_with_a_qstring)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue