Skip to content

Commit

Permalink
Proposed bugfix for path
Browse files Browse the repository at this point in the history
  • Loading branch information
maggelus committed Mar 31, 2023
1 parent b963798 commit ec405b0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions deepdiff/deephash.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections.abc import Iterable, MutableMapping
from collections import defaultdict
from hashlib import sha1, sha256
from pathlib import Path
from enum import Enum
from deepdiff.helper import (strings, numbers, times, unprocessed, not_hashed, add_to_frozen_set,
convert_item_or_items_into_set_else_none, get_doc,
Expand Down Expand Up @@ -420,6 +421,12 @@ def _prep_iterable(self, obj, parent, parents_ids=EMPTY_FROZENSET):
def _prep_bool(self, obj):
return BoolObj.TRUE if obj else BoolObj.FALSE


def _prep_path(self, obj):
type_ = obj.__class__.__name__
return KEY_TO_VAL_STR.format(type_, obj)


def _prep_number(self, obj):
type_ = "number" if self.ignore_numeric_type_changes else obj.__class__.__name__
if self.significant_digits is not None:
Expand Down Expand Up @@ -476,6 +483,9 @@ def _hash(self, obj, parent, parents_ids=EMPTY_FROZENSET):
ignore_encoding_errors=self.ignore_encoding_errors,
)

elif isinstance(obj, Path):
result = self._prep_path(obj)

elif isinstance(obj, times):
result = self._prep_datetime(obj)

Expand Down

0 comments on commit ec405b0

Please sign in to comment.