Decorators and buffer flushing

Ethan Metsger emetsger at obj-sys.com
Thu Feb 28 15:04:38 EST 2008


On Thu, 28 Feb 2008 14:48:55 -0500, <castironpi at gmail.com> wrote:

> Can you reproduce the bug on the console?  Or, try starting with a new
> line in the output.  Or, try a input().

I can reproduce the issue in the console.  I'm not convinced it's actually  
a bug, unless for some reason the interpreter is preventing a buffer flush.

The new line in the output also doesn't work (and isn't desirable anyway),  
and neither does adding input.

Could the problem be that I'm using a with statement?  I have output  
flushed in __enter__:

    def __enter__(self):
       """Ensures that the test begins appropriately.

       In particular, this method will enter the directory specified in the
       instance."""

       self.pardir = os.getcwd()
       os.chdir(self.path)

       sys.stdout.write ("%s" % (self.name.ljust(30),))
       sys.stdout.flush()

       return self

Is it possible that flushing is prohibited until __exit__ is called?


Best,

Ethan (emetsger at obj-sys.com)
http://uppertank.net/ethanm/



More information about the Python-list mailing list