test: encode stderr as utf-8 under python 2
Newer releases of PyPy write unicode objects to stderr when the
PySys_WriteStderr function is invoked, even on Python 2. This means
that we cannot count on the type of the input to the test harness
stderr mock.
@@ -20,7 +20,10 @@ if sys.version_info >= (3,):
raise value
else:
linesep = os.linesep
- StdBufferIO = io.BytesIO
+
+ class StdBufferIO(io.BytesIO):
+ def write(self, data):
+ return super(StdBufferIO, self).write(data.encode('utf-8'))
exec("""\
def reraise(typ, value, tb):
