backport https://github.com/lericson/pylibmc/commit/39b6f9504011df616275d56838a4d0c7766de769