print bypasses calling write method for objects inheriting from file?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed May 30 13:32:23 EDT 2007


En Wed, 30 May 2007 04:24:30 -0300, Peter Otten <__peter__ at web.de>  
escribió:

>> I created an object that inherits from file and was a bit surprised to
>> find that print seems to bypass the write method for objects
>> inheriting from file.  An optimization I suppose.  Does this surprise
>> anyone else at all or am I missing something?
>
> No, your analysis is correct, though I'd consider optimization an  
> euphemism
> for bug here. Noone was annoyed enough to write a patch, it seems.

A one-line patch, I guess, PyFile_CheckExact instead of PyFile_Check. Or a  
few lines, checking if the write method is still the builtin one. As this  
is the third time I see this question I'll try to submit the patch.

-- 
Gabriel Genellina




More information about the Python-list mailing list