Skip to content

Commit 28bff4e

Browse files
Zheaolibarneygale
andcommitted
fix review idea
Co-authored-by: Barney Gale <[email protected]> Signed-off-by: Manjusaka <[email protected]>
1 parent eff160a commit 28bff4e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Lib/pathlib/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,12 @@ def __hash__(self):
209209
try:
210210
return self._hash
211211
except AttributeError:
212-
hash_data = self._tail
213-
if self._drv or self._root:
214-
hash_data = [self._drv + self._root] + self._tail
215-
elif self._tail and self.parser.splitdrive(self._tail[0])[0]:
216-
hash_data = ['.'] + self._tail
217-
if self.parser is not posixpath:
218-
hash_data = [part.lower() for part in hash_data]
219-
self._hash = hash(tuple(hash_data))
212+
if self.parser is posixpath:
213+
self._hash = hash((self.root, tuple(self._tail)))
214+
else:
215+
self._hash = hash((self.drive.lower(),
216+
self.root.lower(),
217+
tuple([part.lower() for part in self._tail])))
220218
return self._hash
221219

222220
def __eq__(self, other):

0 commit comments

Comments
 (0)