[Python-Dev] [Python-3000] Code freeze?

Nick Coghlan ncoghlan at gmail.com
Fri Feb 29 12:39:22 CET 2008

Christian Heimes wrote:
> Barry Warsaw wrote:
>> Okay, let's go ahead and make it official.
>> I plan on cutting the alphas for 2.6 and 3.0 at about 6pm Eastern
>> (UTC-5) time or 2300 UTC.  Let's freeze the tree one hour prior to
>> that: 2200 UTC Friday 29-Feb-2008.
> Linux is looking good. I've fixed some minor Windows issue in the last
> 30 minutes. I found one strange behavior. Some tests were failing
> because iter(fileobj) where fileobj is a tempfile._TemporaryFileWrapper
> failed. Apparently iter() doesn't use __getattr__ to acquire the
> __iter__ method. Is this behavior deliberately?

The interpreter is actually permitted to bypass the instance when 
looking up magic methods. Whether it does or not is implementation 
dependent - even CPython varies its behaviour depending on the specific 
circumstance (e.g. the translation of with statements to bytecode ends 
up using normal GET_ATTR opcodes, so those will see __enter__ and 
__exit__ methods on instances, but most of the magic method lookups from 
C code bypass the instance and go straight to the relevant tp_* slot).

I'd call this behaviour a bug in _TemporaryFileWrapper, since it's 
delegation trick in __getattr__ isn't guaranteed to work for the magic 
methods. I'm actually becoming less and less enamoured of that shortcut 
every day - given that we've already had to spell out the file method 
and property delegation for SpooledTemporaryFile in 2.6, I'm tempted to 
start spelling it out for _TemporaryFileWrapper as well.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list