From e9de49255b6b4a1749b729a02e9fe643c66a042f Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 1 Sep 2011 14:26:33 -0300 Subject: Fix QAbstractFileEngine read and readLine methods to accept data with null bytes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Marcelo Lira Renato Araújo --- PySide/QtCore/typesystem_core.xml | 4 ++-- tests/QtCore/bug_723.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index f450a2901..6b8205e5a 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2363,7 +2363,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); } @@ -2386,7 +2386,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); } diff --git a/tests/QtCore/bug_723.py b/tests/QtCore/bug_723.py index 68ebeab61..319c04bad 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() -- cgit v1.2.3