Skip to content

Commit 241fc8d

Browse files
committed
Adapt directory cache for python2 and python3
1 parent b160b71 commit 241fc8d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pygccxml/parser/directory_cache.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def _load(self):
241241
self.__filename_rep = filename_repository_t(self.__sha1_sigs)
242242

243243
# Read the xml generator from the cache and set it
244-
with open(os.path.join(self.__dir, "gen.dat"), "rb") as gen_file:
244+
with open(os.path.join(self.__dir, "gen.dat"), "r") as gen_file:
245245
utils.xml_generator = gen_file.read()
246246

247247
self.__modified_flag = False
@@ -263,7 +263,7 @@ def _save(self):
263263
self.__filename_rep))
264264

265265
# Read the xml generator from the cache and set it
266-
with open(os.path.join(self.__dir, "gen.dat"), "wb") as gen_file:
266+
with open(os.path.join(self.__dir, "gen.dat"), "w") as gen_file:
267267
gen_file.write(utils.xml_generator)
268268

269269
self.__modified_flag = False
@@ -377,7 +377,7 @@ def _create_config_signature(config):
377377
:rtype: str
378378
"""
379379
m = hashlib.sha1()
380-
m.update(config.working_directory)
380+
m.update(config.working_directory.encode("utf-8"))
381381
for p in config.include_paths:
382382
m.update(p)
383383
for p in config.define_symbols:
@@ -542,13 +542,13 @@ def _get_signature(self, entry):
542542
if not os.path.exists(entry.filename):
543543
return None
544544
try:
545-
f = open(entry.filename)
545+
f = open(entry.filename, "r")
546546
except IOError as e:
547547
print("Cannot determine sha1 digest:", e)
548548
return None
549549
data = f.read()
550550
f.close()
551-
return hashlib.sha1(data).digest()
551+
return hashlib.sha1(data.encode("utf-8")).digest()
552552
else:
553553
# return file modification date...
554554
try:

0 commit comments

Comments
 (0)