[New-bugs-announce] [issue7720] Errors in tests and C implementation of raw FileIO

Pascal Chambon report at bugs.python.org
Sat Jan 16 22:46:01 CET 2010


New submission from Pascal Chambon <chambon.pascal at gmail.com>:

My own fileio implementation fails against the latests versions of the io test suite, under python2.6, because these now require FileIO objects to accept unicode strings in their write methods, whereas the doc mentions raw streams only deal with bytes/bytearrays.

Below is the faulty test (unicode literals or ON). The unicode "xxx" is written to the io.FileIO instance, and the stdlib implementation indeed accepts unicode args (in _fileio.c : "if (!PyArg_ParseTuple(args, "s*", &pbuf)...").

In test_io.py :

   def test_destructor(self):
        record = []
        class MyFileIO(io.FileIO):
            def __del__(self):
                record.append(1)
                io.FileIO.__del__(self)
            def close(self):
                record.append(2)
                io.FileIO.close(self)
            def flush(self):
                record.append(3)
                io.FileIO.flush(self)
        f = MyFileIO(test_support.TESTFN, "w")
        f.write("xxx")
        del f
        self.assertEqual(record, [1, 2, 3])

----------
components: IO
messages: 97910
nosy: pakal
severity: normal
status: open
title: Errors in tests and C implementation of raw FileIO
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7720>
_______________________________________


More information about the New-bugs-announce mailing list