New submission from James Hutchison <jamesghutchi...@gmail.com>: When upgrading from Python 3.1 to Python 3.2 I noticed that when my program closed it printed out a non-consequential AttributeError Exception. My program had a custom class that replaced stdout and stderr for use in a piped program (it flushed the buffer after every print statement)
I was able to reduce my code down to this simple test case that will reproduce the issue. Note that this doesn't show up in idle. code: import sys from time import sleep import subprocess python31loc = r"C:\python31\python.exe"; python32loc = r"C:\python32\python.exe"; myname = "attributeError.py"; class FlushFile(object): #"""Write-only flushing wrapper for file-type objects.""" def __init__(self, f): self.f = f try: self.encoding = f.encoding; except: pass; def write(self, x): self.f.write(x) self.f.flush() # sets stdout and stderr to autoflush def setAutoFlush(): if sys.__stdout__ != None: # will be None in IDLE sys.stdout = FlushFile(sys.__stdout__); sys.stderr = FlushFile(sys.__stderr__); if __name__ == "__main__": setAutoFlush(); if(len(sys.argv) == 1): print("Testing python 3.1"); output = subprocess.check_output("%s %s -output" % (python31loc, myname)); print("Should see no error"); print("Testing python 3.2"); output = subprocess.check_output("%s %s -output" % (python32loc, myname)); print("Should see no error"); sleep(16); Output: Testing python 3.1 Should see no error Testing python 3.2 Exception AttributeError: 'flush' in <__main__.FlushFile object at 0x00C347F0> i gnored Should see no error ---------- components: IO, Windows messages: 135347 nosy: Jimbofbx priority: normal severity: normal status: open title: Attribute error with flush on stdout,stderr type: behavior versions: Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12020> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com