Skip to content

Commit b65022b

Browse files
committed
simpler way of checksumming files in a python 2 and 3 compatible way
1 parent a142f02 commit b65022b

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

pygccxml/parser/declarations_cache.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,9 @@ def file_signature( filename ):
2323
# - This change allows duplicate autogenerated files to be recognized
2424
#return os.path.getmtime( source )
2525
sig = hashlib.md5()
26-
try:
27-
# try default encoding first
28-
f = open(filename, 'r', encoding='utf-8')
29-
buf = f.read()
30-
except UnicodeDecodeError:
31-
# otherwise, try another common encoding
32-
f.close()
33-
f = open(filename, 'r', encoding='iso8859-1')
34-
buf = f.read()
35-
sig.update(buf.encode('utf-8'))
26+
f = open(filename, 'rb')
27+
buf = f.read()
28+
sig.update(buf)
3629
f.close()
3730
return sig.hexdigest()
3831

0 commit comments

Comments
 (0)