Skip to content

Commit

Permalink
Integrate python version into the hash key
Browse files Browse the repository at this point in the history
This prevents subtle issues when the ast changes but gast / beniget / memestra
don't get updated accordingly.

Fix #61
  • Loading branch information
serge-sans-paille committed Aug 6, 2021
1 parent cde5ef6 commit 464043c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions memestra/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,18 @@ class CacheKeyFactory(CacheKeyFactoryBase):
Only the content of the module is taken into account
'''

py_version = sys.version_info

class CacheKey(object):

def __init__(self, module_path, _):

with open(module_path, 'rb') as fd:
module_content = fd.read()
module_hash = hashlib.sha256(module_content).hexdigest()
self.module_hash = module_hash
m = hashlib.sha256()
m.update(py_version)
m.update(module_content)
self.module_hash = m.hexdigest()

@property
def path(self):
Expand Down

0 comments on commit 464043c

Please # to comment.