[PyQt] PyQt load error

John Burnett JBurnett at blizzard.com
Thu May 5 05:49:06 BST 2011

We are running into something that is arguably a bug in PyQt (4.8.3 in our case).

During startup, "PyQt4/uic/port_v*/load_plugin.py" exec's Python code loaded out of a series of text files.  Those files are opened in "PyQt4/uic/objcreator.py", line 91.  The file open call doesn't specify a mode, so it defaults to 'r'.

The issue we're seeing is under OSX, but would apply to Linux as well.  We have a copy of PyQt for OSX in source control being exported to disk from a Windows machine.  When this happens, the py files are being given Windows line endings (CR/LF).  Later, when this copy of PyQt starts under OSX, load_plugin.py's exec dies due to syntax errors in the file buffers it's being passed (the CR/LF's aren't translated to native line endings).

The fix we made is to change objcreator.py to open files with universal line ending support.  e.g. change line 91 from this:

    if load_plugin(open(filename), plugin_globals, plugin_locals):

...to this:

    if load_plugin(open(filename, 'rU'), plugin_globals, plugin_locals):

I'm not sure there's any negative fallout from this.  Thoughts?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110505/bd03b21e/attachment-0001.html>

More information about the PyQt mailing list