[PyQt] newly introduced bug in PyQt 4.8.1 uic.loadUi
Phil Thompson
phil at riverbankcomputing.com
Mon Dec 6 13:25:48 GMT 2010
On Sun, 5 Dec 2010 17:24:06 -0800, "Paul Du Bois" <dubois at doublefine.com>
wrote:
> This change to PyQt4/uic/Loader/loader.py loadUi() breaks support for
> file-like objects,
> but uic.loadUi() is still documented as supporting them:
>
> # Allow the filename to be a QString.
> filename = str(filename)
>
> return self.parse(filename, os.path.dirname(filename))
>
> The use case for file-like objects is wrapping up apps via py2exe or
> similar.
>
> Here is an example of the problem:
>
>>>> from PyQt4 import uic
>>>> help(uic.loadUi)
> Help on function loadUi in module PyQt4.uic:
>
> loadUi(uifile, baseinstance=None)
> loadUi(uifile, baseinstance=None) -> widget
>
> Load a Qt Designer .ui file and return an instance of the user
> interface.
>
> uifile is a file name or file-like object containing the .ui file.
> baseinstance is an optional instance of the Qt base class. If
> specified
> then the user interface is created in it. Otherwise a new instance
> of the
> base class is automatically created.
>
>>>> import StringIO
>>>> f = StringIO.StringIO("foo")
>>>> uic.loadUi(f)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "C:\python26\lib\site-packages\PyQt4\uic\__init__.py", line 185,
> in loadUi
> return DynamicUILoader().loadUi(uifile, baseinstance)
> File "C:\python26\lib\site-packages\PyQt4\uic\Loader\loader.py", line
> 31, in loadUi
> return self.parse(filename, os.path.dirname(filename))
> File "C:\python26\lib\site-packages\PyQt4\uic\uiparser.py", line 817,
> in parse
> document = parse(filename)
> File "C:\python26\lib\xml\etree\ElementTree.py", line 862, in parse
> tree.parse(source, parser)
> File "C:\python26\lib\xml\etree\ElementTree.py", line 579, in parse
> source = open(source, "rb")
> IOError: [Errno 22] invalid mode ('rb') or filename: '<StringIO.StringIO
> instance at 0x00C87A08>'
Should be fixed in tonight's snapshot.
Thanks,
Phil
More information about the PyQt
mailing list