pinterest/pymemcache

MemcacheServerError byte string message

fabtjar opened this issue · 3 comments

When I attempt to set a cache too big the error message is a byte string for pymemcache.exceptions.MemcacheServerError(b'object too large for cache'). I believe this message is coming from the backend but shouldn't we decode it to a regular string as we raise the exception?

jogo commented

Looking over this codebase this has been the default behavior since 108f15c, and changing it risks breaking existing usage. While I couldn't find any cases where there could be unicode in the error message https://github.com/memcached/memcached/search?p=1&q=SERVER_ERROR&type=code I am inclined to say we should leave the exception as bytes so we don't risk breaking existing usage of MemcacheServerError.

If we wanted to risk the break, now would be a good time to do it (as part of the upcoming 4.0, Python 3-only release).

jogo commented

I personally bias towards breaking as few things as possible to reduce the toil required to upgrade.