Here is my implementation of a raw File I/O type for Python 3000, along with unit tests. The tests for repr() fail because I'm not 100% sure what repr() should return (in particular, whether the type should bother remembering the filename just to return in repr()). There are comments at the top of the .c file explaining what remains to be done.
Committed revision 54214. I tweaked a few things; for example O_APPEND doesn't have the semantics we want (it appends on *every write*). I turned it into a module and renamed it to _fileio, the class to _FileIO. The io.py module now imports this and uses it as a base class for *its* FileIO class, if the import works. There are plenty of XXX things. I'll try to get large file support working next; as long as off_t is a 64-bit int this should just work.
Reopening. I'm seeing build warnings and test failures related to the FileIO work when Python is configured with --with-pydebug. When compiling Modules/_fileio.c, gcc complains about "PyFileIO_Type undeclared"; because the _fileio module fails to build, both test_io and test_fileio fail. This occurs even after "make distclean". I have r54216 of p3yk, gcc 3.4.6. _fileio.c compiles successfully if Python is configured without --with-pydebug.
It's missing a forward declaration of PyFileIO_Type near the top of the file so the PyFileIO_Check() macro works. Currently PyCheck_FileIO is only called inside of an assert() macro, which is why this problem only surfaces in a debug build. Patch to add the forward declaration attached. File Added: pyfileio_type.diff