Fixed imcompatibility with PySide.
(cherry picked from commit 2df4b74907ccc33767f42651c9a38f8367f193d5)