Skip to content

Commit 2aab2f2

Browse files
committed
Better support for unicode cache entries
1 parent 69cdf75 commit 2aab2f2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/pip/_internal/cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _hash_dict(d):
3434
for k in sorted(d.keys()):
3535
h.update(k.encode())
3636
h.update("=".encode())
37-
h.update(d[k].encode())
37+
h.update(d[k].encode("utf-8"))
3838
h.update(b"\0")
3939
return h.hexdigest()
4040

tests/unit/test_cache.py

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def test_cache_hash():
4949
assert h == "c7d60d08b1079254d236e983501fa26c016d58d16010725b27ed0af2"
5050
h = _hash_dict({"url": "https://g.c/o/r", "subdirectory": "sd"})
5151
assert h == "9cba35d4ccf04b7cde751b44db347fd0f21fa47d1276e32f9d47864c"
52+
h = _hash_dict({"subdirectory": u"/\xe9e"})
53+
assert h == "727d53e3305684344078965b1c0771f57f180c00516aaeb6ed8b36ce"
5254

5355

5456
def test_get_path_for_link_legacy(tmpdir):

0 commit comments

Comments
 (0)