#16993: In core.cache.backends.BaseCache.default_key_func join expects character
string
----------------------------+----------------------
     Reporter:  adsworth    |      Owner:  adsworth
         Type:  Bug         |     Status:  new
    Component:  Python 3    |    Version:  1.3
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  1
Easy pickings:  0           |      UI/UX:  0
----------------------------+----------------------
 The join in
 
[[source:django/trunk/django/core/cache/backends/base.py#L26|core.cache.backends.BaseCache.default_key_func]]
 expects a character string instead of a byte string. `key_prefix` is
 encoded to a byte string in `BaseCache.__init__` and `key` is encoded
 directly in `default_key_func`.

 The simple solution is wrapping `key_prefix` and `key` with `str()` for
 which a patch is attached. fix-cache.base.backends.get_default_key.patch

 This feels backwards though, but I'm not sure about the best solution. How
 about calling smart_str on the result of the join and getting rid of the
 smart_str on `key_prefix` and `key`? For this solution I also attached a
 patch. This patch also works fine in py2.X if the key_prefix is a unicode
 string that contains ÖÄÜ!^. fix-cache.base.backends.get_default_key-
 smart_str_on_result.patch

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16993>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to