Commit 2ca61ff0 authored by Stefan Behnel's avatar Stefan Behnel

Simplify file hashing code in cythonize() dependency tracking.

parent b306bc04
......@@ -113,18 +113,14 @@ def nonempty(it, error_msg="expected non-empty iterator"):
@cached_function
def file_hash(filename):
path = os.path.normpath(filename.encode("UTF-8"))
prefix = (str(len(path)) + ":").encode("UTF-8")
path = os.path.normpath(filename)
prefix = ('%d:%s' % (len(path), path)).encode("UTF-8")
m = hashlib.md5(prefix)
m.update(path)
f = open(filename, 'rb')
try:
with open(path, 'rb') as f:
data = f.read(65000)
while data:
m.update(data)
data = f.read(65000)
finally:
f.close()
return m.hexdigest()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment