Fix sanitizing cache key under Python 3