Author eric.smith
Recipients eric.smith, gvanrossum, ned.deily, steven.daprano
Date 2018-02-25.17:25:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519579557.73.0.467229070634.issue32929@psf.upfronthosting.co.za>
In-reply-to
Content
Here's the simplest way I can describe this, and it's also the table used inside the code.  The column "has-explicit-hash?" is trying to answer the question "is there a __hash__ function defined in this class?". It is set to False if either __hash__ is missing, or if __hash__ is None and there's an __eq__ function. I'm assuming that the __hash__ is implicit in the latter case.

# Decide if/how we're going to create a hash function.  Key is
#  (unsafe_hash, eq, frozen, does-hash-exist).  Value is the action to
#  take.
# Actions:
#  '':          Do nothing.
#  'none':      Set __hash__ to None.
#  'add':       Always add a generated __hash__function.
#  'exception': Raise an exception.
#
#                +-------------------------------------- unsafe_hash?
#                |      +------------------------------- eq?
#                |      |      +------------------------ frozen?
#                |      |      |      +----------------  has-explicit-hash?
#                |      |      |      |
#                |      |      |      |        +-------  action
#                |      |      |      |        |
#                v      v      v      v        v
_hash_action = {(False, False, False, False): (''),
                (False, False, False, True ): (''),
                (False, False, True,  False): (''),
                (False, False, True,  True ): (''),
                (False, True,  False, False): ('none'),
                (False, True,  False, True ): (''),
                (False, True,  True,  False): ('add'),
                (False, True,  True,  True ): (''),
                (True,  False, False, False): ('add'),
                (True,  False, False, True ): ('exception'),
                (True,  False, True,  False): ('add'),
                (True,  False, True,  True ): ('exception'),
                (True,  True,  False, False): ('add'),
                (True,  True,  False, True ): ('exception'),
                (True,  True,  True,  False): ('add'),
                (True,  True,  True,  True ): ('exception'),
                }

PR will be ready as soon as I clean a few things up.
History
Date User Action Args
2018-02-25 17:25:57eric.smithsetrecipients: + eric.smith, gvanrossum, ned.deily, steven.daprano
2018-02-25 17:25:57eric.smithsetmessageid: <1519579557.73.0.467229070634.issue32929@psf.upfronthosting.co.za>
2018-02-25 17:25:57eric.smithlinkissue32929 messages
2018-02-25 17:25:57eric.smithcreate