Opened 12 years ago
Last modified 7 years ago
#20584 closed Bug
Django's Memcached backend get_many() doesn't handle generators — at Initial Version
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Core (Cache system) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When the "keys" parameter to get_many() is a generator, the values will be lost in the zip function.
https://github.com/django/django/blob/master/django/core/cache/backends/memcached.py#L93
Here's a simplified code example:
def make_key(k):
return k
user_ids = (11387, 1304318)
keys = ('user_%d' % x for x in user_ids)
new_keys = map(lambda x: make_key(x), keys)
m = dict(zip(new_keys, keys))
assert( m == {} )
I believe this is related to this zip() behaviour: http://stackoverflow.com/questions/11210300/why-does-zip-drop-the-values-of-my-generator
I encountered this bug when upgrading from django 1.3 to django 1.5.1
Note:
See TracTickets
for help on using tickets.