[Idle-dev] (IOError: [Errno 9] Bad file descriptor) in IDLE for Python 2.3.4 (final)

Kurt B. Kaiser kbk at shore.net
Sun Jul 4 16:02:46 EDT 2004

Dragonfirebane at aol.com writes:

>   File "C:\PROGRA~1\lib\idlelib\ScriptBinding.py", line 135, in 
> run_module_event
>     code = self.checksyntax(filename)
>   File "C:\PROGRA~1\lib\idlelib\ScriptBinding.py", line 96, in checksyntax
>     return compile(source, filename, "exec")
>   File "C:\PROGRA~1\lib\warnings.py", line 116, in warn_explicit
>     showwarning(message, category, filename, lineno)
>   File "C:\PROGRA~1\lib\idlelib\PyShell.py", line 55, in idle_showwarning
>     file.write(warnings.formatwarning(message, category, filename, lineno))
> IOError: [Errno 9] Bad file descriptor

This problem has two levels.  First, the SyntaxWarning (you assigned
to a global before declaring it) was going to __stderr__ and not to
the shell.  I checked in a fix to send SyntaxWarning to the shell
and also implemented the warnings.py policy of skipping the warning if
the output stream was bogus. (Introduced at warnings.py 1.17 11Sep02)

The second level is, why is your sys.__stderr__ call returning a bad
file descriptor?  Since you saw the error, you must be using a dos
box, but usually this problem shows up only when using pythonw and
only when trying to write more than 4096 bytes (which is not the case
for this warning).

I can't duplicate the problem when running your code on W2K using the
normal pythonw call of IDLE.

1. Please post here complete details about your Windows system and how
   you start IDLE.  

2. Try adding the lines

zprint "*** sys.__stdout__: ", sys.__stdout__
print "*** sys.__stderr__: ", sys.__stderr__

just before that line 55 in PyShell.py and post the result of the
Warning error again here.



More information about the IDLE-dev mailing list