Fix pypy 2.4 regression, #952

Added suggested solution from Armin Rigo, https://bitbucket.org/pypy/pypy/issue/1887/regression-in-240-streamio .