Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚑 🐍3 Encode Unicode-Objects Before Hashing #30

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions pixiedust_node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def clearCache(self):
# the cache contains the key (variable name) against an MD5 of the
# JSON form of the value. This makes the cache more compact.
def setCache(self, key, val):
self.cache[key] = hashlib.md5(json.dumps(val)).hexdigest()
self.cache[key] = hashlib.md5(json.dumps(val).encode("utf8")).hexdigest()

# check whether key is in cache and whether it equals val by comparing
# the hash of its JSON value with what's in the cache
def inCache(self, key, val):
hash = hashlib.md5(json.dumps(val)).hexdigest()
hash = hashlib.md5(json.dumps(val).encode("utf8")).hexdigest()
return (key in self.cache and self.cache[key] == hash)

def post_execute(self):
Expand Down Expand Up @@ -212,7 +212,7 @@ def __init__(self, path):

# watch Python variables for changes
self.vw = VarWatcher(get_ipython(), self.ps)

# create thread to read this process's output
NodeStdReader(self.ps, self.vw)

Expand Down Expand Up @@ -275,6 +275,3 @@ def uninstall(self, module):

def list(self):
self.cmd('list', None)