[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt]  [Bug report] PyQt5.QtCore.Alignment not hashable
From:       Gabriel Marcilio <gaheris.sc () gmail ! com>
Date:       2017-04-12 16:16:56
Message-ID: CAHhagFUhXgtfrmoTijBnZMnOKAFj++XxapwU8pbiZ4a02d49Yg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello

I am having issues with PyQt5.QtCore.Alignment values. I cannot use then as
dict keys because those values are not hashable.
The issue can be seen in the following snippet:

    # AlignmentFlag Works fine
    alignment_flag = Qt.AlignTop
    assert hasattr(alignment_flag, '__hash__')
    assert hash(alignment_flag) == 32
    assert alignment_flag.__hash__() == 32

    # Alignment is unhashable
    alignment  =  Qt.AlignTop | Qt.AlignLeft
    assert hasattr(alignment, '__hash__')
    assert hash(alignment) != 0 # <- TypeError: unhashable type: 'Alignment'
    assert alignment.__hash__() != 0  # <- TypeError: 'NoneType' object is
not callable

The Alignment class overrides the __eq__ method but does not provide an
implementation for __hash__ method, and this makes the object unhashable.

This code worked with python 2.7 pyqt 5.5.1

I am having issues with python 3.5.2 and pyqt  5.6.0

Thanks in advance

Gabriel

[Attachment #5 (text/html)]

<div dir="ltr"><div>Hello<br></div><div><br></div><div>I am having issues with \
PyQt5.QtCore.Alignment values. I cannot use then as dict keys because those values \
are not hashable.</div><div>The issue can be seen in the following \
snippet:</div><div><br></div><div>      # AlignmentFlag Works fine</div><div>      \
alignment_flag = Qt.AlignTop</div><div>      assert hasattr(alignment_flag, \
&#39;__hash__&#39;)</div><div>      assert hash(alignment_flag) == 32</div><div>      \
assert alignment_flag.__hash__() == 32</div><div>       </div><div>      # Alignment \
is unhashable</div><div>      alignment   =   Qt.AlignTop | Qt.AlignLeft</div><div>   \
assert hasattr(alignment, &#39;__hash__&#39;)</div><div>      assert hash(alignment) \
!= 0 # &lt;- TypeError: unhashable type: &#39;Alignment&#39;</div><div>      assert \
alignment.__hash__() != 0   # &lt;- TypeError: &#39;NoneType&#39; object is not \
callable</div><div><br></div><div>The Alignment class overrides the __eq__ method but \
does not provide an implementation for __hash__ method, and this makes the object \
unhashable.</div><div><br></div><div>This code worked with python 2.7 pyqt \
5.5.1</div><div><br></div><div>I am having issues with python 3.5.2 and pyqt   \
5.6.0</div><div><br></div><div>Thanks in \
advance</div><div><br></div><div>Gabriel</div><div><br></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic