Subclassing file class

Jeff Epler jepler at unpythonic.net
Wed Aug 4 08:03:04 EDT 2004


"print>>" uses the bytecode PRINT_ITEM_TO which uses
PyFile_WriteString() which uses PyFile_Check() which returns True for
your "fout", which leads directly to a call to fputs.

Instead, PyFile_WriteString() should probably use PyFile_CheckExact()
(which doesn't exist yet) before taking that branch of the code.

I also notice that the return value of that fputs is not checked in that
function!

For now, you could use containment and delegation instead of
subclassing, just like in Python before new-style classes.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040804/062c8911/attachment.sig>


More information about the Python-list mailing list