Details
Description
In this case, I get the error : "TypeError: can't pickle PenStyle objects".
Since under the hood these enum values are just integers, I would imagine that implementing pickling shouldn't be too hard, and would be very useful.
One thing that confuses me is that pickling fails, but I can use Qt.SolidLine as a key in a dictionary, which is usually only possible with pickleable objects, so maybe enum values are supposed to be pickleable and this is actually a bug? :
from PySide2.QtCore import * d = { Qt.SolidLine : "Solid"} d.keys() [PySide.QtCore.Qt.PenStyle.SolidLine] import StringIO import pickle sio = StringIO.StringIO() pickle.dump(Qt.SolidLine, sio) Traceback (most recent call last): File "<pyshell#20>", line 1, in <module> pickle.dump(Qt.SolidLine, sio) File "C:\Python27\lib\pickle.py", line 1370, in dump Pickler(file, protocol).dump(obj) File "C:\Python27\lib\pickle.py", line 224, in dump self.save(obj) File "C:\Python27\lib\pickle.py", line 306, in save rv = reduce(self.proto) File "C:\Python27\lib\copy_reg.py", line 70, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle PenStyle objects
Attachments
For Gerrit Dashboard: PYSIDE-15 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
298391,6 | shiboken: Rework sbkenum by fixing refcounts | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
298845,23 | Support pickling of Qt Enum objects | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
299176,21 | Implement __qualname__ and correct __module__ for classes | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
300412,4 | shiboken: Make AutoDecRef safe | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
300619,1 | shiboken: Rework sbkenum by fixing refcounts | tqtc/5.15 | pyside/tqtc-pyside-setup | Status: ABANDONED | 0 | 0 |
300642,1 | shiboken: Make AutoDecRef safe | tqtc/5.15 | pyside/tqtc-pyside-setup | Status: ABANDONED | 0 | 0 |