Skip to content

Instantly share code, notes, and snippets.

@altendky
Created September 29, 2017 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altendky/7096674b424af3ed8d80e47a41af3169 to your computer and use it in GitHub Desktop.
Save altendky/7096674b424af3ed8d80e47a41af3169 to your computer and use it in GitHub Desktop.
sys.version: 3.6.2 (default, Sep 15 2017, 22:53:56)
[GCC 5.4.0 20160609]
sys.platform: linux
QT_VERSION_STR: 5.9.1
PYQT_VERSION_STR: 5.9
o.signal: <bound PYQT_SIGNAL signal of C object at 0x7f9523b1b1f8>
inspect.isdatadescriptor(o.signal): False
inspect.ismethoddescriptor(o.signal): False
inspect.ismemberdescriptor(o.signal): False
a: <bound PYQT_SIGNAL signal of C object at 0x7f9523b1b1f8>
b: <bound PYQT_SIGNAL signal of C object at 0x7f9523b1b1f8>
weak ref succeeded for <PyQt5.QtCore.QObject object at 0x7f9523b1b288>
Traceback (most recent call last):
File "pyqtweakref.py", line 38, in <module>
weakref.ref(it)
TypeError: cannot create weak reference to 'PyQt5.QtCore.pyqtBoundSignal' object
c: <bound PYQT_SIGNAL signal of C object at 0x7f9523b1b1f8>
import inspect
import sys
import traceback
import weakref
import PyQt5.QtCore
import PyQt5.QtWidgets
print('sys.version:', sys.version)
print('sys.platform:', sys.platform)
print('QT_VERSION_STR:', PyQt5.QtCore.QT_VERSION_STR)
print('PYQT_VERSION_STR:', PyQt5.QtCore.PYQT_VERSION_STR)
class C(PyQt5.QtCore.QObject):
signal = PyQt5.QtCore.pyqtSignal()
o = C()
print('o.signal:', o.signal)
print('inspect.isdatadescriptor(o.signal):', inspect.isdatadescriptor(o.signal))
print('inspect.ismethoddescriptor(o.signal):', inspect.ismethoddescriptor(o.signal))
print('inspect.ismemberdescriptor(o.signal):', inspect.ismemberdescriptor(o.signal))
a = o.signal
b = o.signal
print('a:', a)
print('b:', b)
them = (
PyQt5.QtCore.QObject(),
o.signal,
)
for it in them:
sys.stdout.flush()
try:
weakref.ref(it)
except:
traceback.print_exc()
else:
print('weak ref succeeded for', it)
c = o.signal
print('c:', c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment