Author Antony.Lee
Recipients Antony.Lee, brett.cannon, larry, ncoghlan, python-dev, yselivanov
Date 2014-08-15.06:01:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1408082500.66.0.213200245911.issue20334@psf.upfronthosting.co.za>
In-reply-to
Content
The hash function of the Signature class is actually incompatible with the definition of Signature equality, which doesn't consider the order of keyword-only arguments:

>>> from inspect import signature
>>> s1 = signature(lambda *, x, y: None); s2 = signature(lambda *, y, x: None)
>>> s1 == s2
True
>>> hash(s1) == hash(s2)
False

Actually the implementation of Signature.__eq__ seems way too complicated; I would suggest making a helper method returning (return_annotation, tuple(non-kw-only-params), frozenset(kw-only-params)) so that __eq__ can compare these values while __hash__ can hash that tuple.
History
Date User Action Args
2014-08-15 06:01:40Antony.Leesetrecipients: + Antony.Lee, brett.cannon, ncoghlan, larry, python-dev, yselivanov
2014-08-15 06:01:40Antony.Leesetmessageid: <1408082500.66.0.213200245911.issue20334@psf.upfronthosting.co.za>
2014-08-15 06:01:40Antony.Leelinkissue20334 messages
2014-08-15 06:01:40Antony.Leecreate