Permalink
Browse files

Merge branch 'pickle-integration'

  • Loading branch information...
jneen committed Aug 21, 2012
2 parents bd4e355 + b61f52e commit f6b0a57c9993d37775633ab07d313ff8d2627e05
Showing with 5 additions and 10 deletions.
  1. +5 −2 src/cache/__init__.py
  2. +0 −8 test/cache_test.py
View
@@ -1,3 +1,6 @@
+import hashlib
+import pickle
+
# local dependencies
from .version import __version__
@@ -168,9 +171,9 @@ def _prepare_key(key, *args, **kwargs):
items = kwargs.items()
items.sort()
hashable_args = (args, tuple(items))
- args_key = hash(hashable_args)
+ args_key = hashlib.md5(pickle.dumps(hashable_args)).hexdigest()
- return "%s/args:%x" % (key, args_key)
+ return "%s/args:%s" % (key, args_key)
class LocalCache:
View
@@ -122,11 +122,3 @@ def expensive(*a, **kw):
assert len(keys) == 2, "only two keys are set"
assert ("mykey/args:") in keys[0]
-
- # arguments must be hashable
- try:
- expensive([1, 2, 3])
- except TypeError as e:
- assert e.message == "unhashable type: 'list'"
- else:
- assert False, "should throw TypeError"

0 comments on commit f6b0a57

Please sign in to comment.