On 21. 07. 24 22:48, Barry wrote:
On 21 Jul 2024, at 10:22, Paul Howarth <paul@xxxxxxxxxxxx> wrote:
Hence the check is:
except UnsupportedAlgorithm as e:
return e._reason is _Reasons.UNSUPPORTED_HASH
This may be a case of the e._reason being the correct int value of _ Reasons.UNSUPPORTED_HASH by not the singleton.
So “is” fails but when == coerces to int it is True.
You would need to print out both values to see if this is the case.
They have the same repr, type, int value. They have different IDs.
... except UnsupportedAlgorithm as e:
... ex = e
>>> ex._reason
_Reasons.UNSUPPORTED_HASH
>>> _Reasons.UNSUPPORTED_HASH
_Reasons.UNSUPPORTED_HASH
>>> type(_Reasons.UNSUPPORTED_HASH) == type(ex._reason)
True
>>> type(_Reasons.UNSUPPORTED_HASH) is type(ex._reason)
True
>>> int(ex._reason)
1
>>> int(_Reasons.UNSUPPORTED_HASH)
1
>>> ex._reason == _Reasons.UNSUPPORTED_HASH
True
>>> ex._reason is _Reasons.UNSUPPORTED_HASH
False
>>> id(ex._reason)
140685770732432
>>> id(_Reasons.UNSUPPORTED_HASH)
140685770728432
--
Miro Hrončok
--
Phone: +420777974800
Fedora Matrix: mhroncok
--
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue