[PySide] strange QObject bahaviour on Python 3.2 (Windows and Linux)
Roman Lacko
backup.rlacko at gmail.com
Wed Sep 12 12:20:28 CEST 2012
Hi,
I have discovered strange bahaviour while testing qtdemo.py under Python 3.2.
Plase look at sample code and the comment prefixed XXX:
>>>
from PySide import QtCore
class MenuManager(QtCore.QObject):
pInstance = None
@classmethod
def instance(cls):
if cls.pInstance is None:
cls_inst = cls()
cls.pInstance = cls_inst
# XXX: the cls.pInstance is None but cls_inst is NOT None !!!
return cls.pInstance
# This will allways return None under Python 3.2
menuManagerInstance = MenuManager.instance()
print(menuManagerInstance)
<<<
Under Python 2.6 and 2.7 the code work as expected (cls.pInstance is NOT None)
If MenuManager inherits from object it will work (class
MenuManager(object)), so there is something wrong with QObject
wrapper...
Under PyQt4 it works fine.
I have absolutely no idea what is going on here.
Regards
Roman
More information about the PySide
mailing list