diff --git a/bin/swh-hash-file b/bin/swh-hash-file
index 7ad22a8d0f7e8b8500977be4de2940ddc1cd5308..c30de78f2ebb4cdd7956e762b4310c89e1528939 100755
--- a/bin/swh-hash-file
+++ b/bin/swh-hash-file
@@ -15,7 +15,7 @@ HASH_ALGO = 'sha1_git'
 
 
 def hash_file(fname):
-    return hash_to_hex(Content.from_file(path=fname).hash)
+    return hash_to_hex(Content.from_file(path=fname.encode()).hash)
 
 
 def main(fnames):