[PyQt] PyQt load error

Phil Thompson phil at riverbankcomputing.com
Tue May 10 12:03:12 BST 2011


On Thu, 5 May 2011 04:49:06 +0000, John Burnett <JBurnett at blizzard.com>
wrote:
> 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?

Seems reasonable - it will be in tonight's snapshot.

Phil


More information about the PyQt mailing list