You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@simple_hash_value.setter
def simple_hash_value(self, value):
if value and not isinstance(value, SimpleHashValue):
value = SimpleHashValue(value)
self._simple_hash_value = value
should use same logic as in constructor,as follows:
@simple_hash_value.setter
def simple_hash_value(self, hash_value):
if hash_value and not isinstance(hash_value, SimpleHashValue):
hash_value = SimpleHashValue(hash_value)
self._simple_hash_value = hash_value
if not hash_value:
# If not provided or an empty string, don't assign the type
self.type_ = None
elif len(hash_value.value) == 32:
self.type_ = Hash.TYPE_MD5
elif len(hash_value.value) == 40:
self.type_ = Hash.TYPE_SHA1
elif len(hash_value.value) == 64:
self.type_ = Hash.TYPE_SHA256
else:
self.type_ = Hash.TYPE_OTHER
The text was updated successfully, but these errors were encountered:
I don't think we want the auto-typing to occur every time we set the hash value. The reason is that it is possible to have a TYPE_OTHER hash of length 32, 40, or 64, and we'd want the following two blocks of code to behave identically:
h = Hash()
h.simple_hash_value = "0123456789abcdef0123456789abcdef"
h.type_ = Hash.TYPE_OTHER
With this change, then h2.type_ would be set to TYPE_MD5 after the second block. Basically, we never want to modify the type of hash after the user has set it, as this could be potentially unexpected behavior.
I'm going to change the auto-typing feature of the Hash so that it executes whenever the simple_hash_value is modified and the the type_ is set to None (that is, before it has been set by the user).
simple_hash_value setter was:
should use same logic as in constructor,as follows:
The text was updated successfully, but these errors were encountered: