|
1 | 1 | #!/usr/bin/env python |
2 | 2 | import inspect |
3 | 3 | import logging |
| 4 | +import datetime |
4 | 5 | from collections.abc import Iterable, MutableMapping |
5 | 6 | from collections import defaultdict |
6 | 7 | from hashlib import sha1, sha256 |
@@ -186,7 +187,8 @@ def __init__(self, |
186 | 187 | # the only time it should be set to False is when |
187 | 188 | # testing the individual hash functions for different types of objects. |
188 | 189 | self.apply_hash = apply_hash |
189 | | - self.type_check_func = type_is_subclass_of_type_group if ignore_type_subclasses else type_in_type_group |
| 190 | + self.type_check_func = type_in_type_group if ignore_type_subclasses else type_is_subclass_of_type_group |
| 191 | + # self.type_check_func = type_is_subclass_of_type_group if ignore_type_subclasses else type_in_type_group |
190 | 192 | self.number_to_string = number_to_string_func or number_to_string |
191 | 193 | self.ignore_private_variables = ignore_private_variables |
192 | 194 | self.encodings = encodings |
@@ -455,6 +457,10 @@ def _prep_datetime(self, obj): |
455 | 457 | obj = datetime_normalize(self.truncate_datetime, obj) |
456 | 458 | return KEY_TO_VAL_STR.format(type_, obj) |
457 | 459 |
|
| 460 | + def _prep_date(self, obj): |
| 461 | + type_ = 'datetime' # yes still datetime but it doesn't need normalization |
| 462 | + return KEY_TO_VAL_STR.format(type_, obj) |
| 463 | + |
458 | 464 | def _prep_tuple(self, obj, parent, parents_ids): |
459 | 465 | # Checking to see if it has _fields. Which probably means it is a named |
460 | 466 | # tuple. |
@@ -505,6 +511,9 @@ def _hash(self, obj, parent, parents_ids=EMPTY_FROZENSET): |
505 | 511 | elif isinstance(obj, times): |
506 | 512 | result = self._prep_datetime(obj) |
507 | 513 |
|
| 514 | + elif isinstance(obj, datetime.date): |
| 515 | + result = self._prep_date(obj) |
| 516 | + |
508 | 517 | elif isinstance(obj, numbers): |
509 | 518 | result = self._prep_number(obj) |
510 | 519 |
|
|
0 commit comments