[PyQt] Bug in PyQt5.Qt
Kovid Goyal
kovid at kovidgoyal.net
Fri Jun 13 18:08:30 BST 2014
I confirmed it, the following implementation fixes the bug:
static void sip_import_component_module(PyObject *d, const char *name)
{
#if PY_VERSION_HEX >= 0x02050000
PyObject *mod = PyImport_ImportModule(name);
#else
PyObject *mod = PyImport_ImportModule((char *)name);
#endif
/*
* Note that we don't complain if the module can't be imported. This
* is a favour to Linux distro packagers who like to split PyQt into
* different sub-packages.
*/
if (mod)
{
PyDict_Merge(d, PyModule_GetDict(mod), 0);
Py_DECREF(mod);
} else PyErr_Clear(); // Without this subsequent PyImport_Importmodule calls fail
}
Kovid.
On Fri, Jun 13, 2014 at 10:12:15PM +0530, Kovid Goyal wrote:
> Hi Phil,
>
> Reading the source code of the PyQt5.Qt module, it is supposed to work
> even if some of the PyQt modules are missing. It does not. For example,
> remove the QtMultimedia.so module and run
>
> python -c "from PyQt5.Qt import QStyle"
>
> This raises an import error. But
>
> python -c "import PyQt5.QtWidgets; from PyQt5.Qt import QStyle"
>
> works.
>
> My best guess is that PyImport_ImportModule requires PyErr_Clear()
> between invocations. (I am away from my dev machine and cant test it
> right now).
>
> I'd appreciate if this could be fixed as it breaks calibre on linux
> distros where PyQt is only partially installed. I am working around it
> for the moment by importing PyQt5.QtWebKitIwdgets very early in calibre
> initialization, but this is less than optimal for obvious reasons.
>
> I could implement a more robust solution by implementing a meta import
> hook, but I'd rather not spend the time on that if it can be fixed
> simply in PyQt5.
>
> Thanks,
>
> Kovid.
>
> --
> _____________________________________
>
> Dr. Kovid Goyal
> http://www.kovidgoyal.net
> http://calibre-ebook.com
> _____________________________________
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
_____________________________________
Dr. Kovid Goyal
http://www.kovidgoyal.net
http://calibre-ebook.com
_____________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140613/78f01d48/attachment.sig>
More information about the PyQt
mailing list