Apply patch from https://bugs.pypy.org/msg5188