Unable to flush stderr

Has something gone haywire? Let us know about it!
Post Reply
User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Unable to flush stderr

Post by Scorbie » September 11th, 2016, 11:35 am

I am using golly 2.8b1 and the following code results in an error.

Code: Select all

import sys
sys.stderr.flush()
I couldn't get the unittest module to work because of this, but I gave up to use it anyway, so not too important.
Edit: the error message:

Code: Select all

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/scorbie/.golly/golly_clip.py", line 2, in <module>
    sys.stderr.flush()
AttributeError: StderrCatcher instance has no attribute 'flush'

User avatar
Andrew
Moderator
Posts: 919
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Unable to flush stderr

Post by Andrew » September 13th, 2016, 11:15 pm

The error happens because Golly redefines sys.stderr to an internal class (StderrCatcher) that captures all error messages in a string that Golly can then display in a dialog box.

You could probably avoid the error by doing something like "sys.stderr.flush = pass" after importing sys.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: Unable to flush stderr

Post by Scorbie » September 16th, 2016, 10:40 am

Andrew wrote:You could probably avoid the error by doing something like "sys.stderr.flush = pass" after importing sys.
Ah! I'll try that next time. Thanks!

Post Reply