unicode support in function_key_generator on Python2

Issue #94 new
Wolfgang Schnerring
created an issue

function_key_generator defines to_str=compat.string_type by default, which is str on Python2 (so breaks when the function gets non-ascii arguments).

The tests don't catch this, because they explicitly pass to_str=compat.text_type, which does the right thing.

Are the backwards-compatibility concerns, or could the default be changed to text_type, which would certainly be less... surprising, out-of-the-box.

Comments (3)

  1. Morgan Fainberg

    My concern with making this change is related to the backend libraries. I'm looking into how this ends up getting handled in the variety of cases and if they handle the byte_str differently than the text_string. We are dealing with what we are potentially sending to the memcached/redisserver/etc as the cache key, and in some libraries we might be scraping by simply based upon the fact that we have always been passing a c-string (byte_str) instead of the alternative.

    An alternative would be to force a .encode() as the default.

    With all of that said, I am not outright opposed to this change. I am slightly concerned that we're changing a default behavior (which I tend to prefer to save for a major version bump). If we are changing this, I prefer not needing to be clever about encoding.

  2. Log in to comment