summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-09-01 14:26:33 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-09-01 15:51:03 -0300
commit56fc423f2665ef54d7b5739a857f69f657187190 (patch)
treea3b9bfb5b71f4c56f95c0cbef575d428d35e4a78
parentabadd5078f7ee4257838b321286220fb27cdd17b (diff)
downloadpyside-56fc423f2665ef54d7b5739a857f69f657187190.tar.gz
pyside-56fc423f2665ef54d7b5739a857f69f657187190.tar.xz
pyside-56fc423f2665ef54d7b5739a857f69f657187190.zip
Fix QAbstractFileEngine read and readLine methods to accept data with null bytes.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Renato Ara├║jo <renato.filho@openbossa.org>
-rw-r--r--PySide/QtCore/typesystem_core.xml4
-rw-r--r--tests/QtCore/bug_723.py5
2 files changed, 4 insertions, 5 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 55dbd08..22d33a9 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -2371,7 +2371,7 @@
%out = -1;
} else {
%out = PyString_GET_SIZE((PyObject*)%PYARG_0);
- qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1);
+ memcpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out);
}
</conversion-rule>
</modify-argument>
@@ -2394,7 +2394,7 @@
%out = -1;
} else {
%out = PyString_GET_SIZE((PyObject*)%PYARG_0);
- qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1);
+ memcpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out);
}
</conversion-rule>
</modify-argument>
diff --git a/tests/QtCore/bug_723.py b/tests/QtCore/bug_723.py
index 68ebeab..319c04b 100644
--- a/tests/QtCore/bug_723.py
+++ b/tests/QtCore/bug_723.py
@@ -5,7 +5,7 @@ class MyFileEngine (QAbstractFileEngine):
def __init__(self):
QAbstractFileEngine.__init__(self)
- self.contents = "Foo bar for the win!"
+ self.contents = "Foo \0bar for the win!"
self.pos = 0
def open(self, mode):
@@ -27,7 +27,6 @@ class MyFileEngine (QAbstractFileEngine):
class MyFileEngineHandler (QAbstractFileEngineHandler):
def create(self, fileName):
- print "hey ho: ", fileName
if fileName.startswith("foo:/"):
return MyFileEngine()
return None
@@ -42,7 +41,7 @@ class TestBug723 (unittest.TestCase):
assert(f.open(QFile.ReadOnly | QFile.Text))
contents = f.readAll()
- self.assertEqual(contents, "Foo bar for the win!")
+ self.assertEqual(contents, "Foo \0bar for the win!")
f.close()