Python Error from Apress book

Dave Angel davea at ieee.org
Wed Jul 8 05:35:54 EDT 2009



Gabriel Genellina wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">En Tue, 
> 07 Jul 2009 09:55:13 -0300, Dave Angel <davea at ieee.org> escribió:
>> Gabriel Genellina wrote:
>>> En Mon, 06 Jul 2009 19:56:40 -0300, matt0177 <matt0177 at gmail.com> 
>>> escribió:
>
>>>> When I try to run the command as outlined in
>>>> the book "simple_markup2.py < test_input.txt > test_output.html i 
>>>> get the
>>>> following error every time.
>>>>
>>>> IOError: [Errno 9] Bad file descriptor
>>>
>>> That's a Windows problem. When you execute the script as itself 
>>> (either as you do in the command line, or by double-clicking on it), 
>>> it doesn't have valid standard handles.
>>> You have to invoke Python explicitely:
>>>
>>> python simple_markup2.py < test_input.txt > test_output.html
>>>
>>> (you may need to specify the full path to python.exe, or add the 
>>> directory where Python is installed to your system PATH).
>>>
>> I use stdout this way all the time, with no problem (python 2.6, 
>> Windows XP).  But as you point out, stdin redirection doesn't seem to 
>> work using the file associations.  I do get a different error though. 
>> When I look at sys.stdin, it shows an open file, with handle of zero, 
>> as expected.  But when I do a raw_input(), it gets:
>>      EOFError: EOF when reading a line
>
> I think the error depends on the specific OS version/service pack. But 
> at least on XP this appears to fix it:
>
> http://support.microsoft.com/kb/321788/en-us
>
Thanks for the link.  Looking at that one, it indicates that Windows 
2000 fixed it in SP4, and XP fixed it in Sp1.  But I'm already running 
XP SP3, so I wonder if it's something new.

Matt, what OS version are you running, and exactly what is happening 
when the error occurs?  (you should be able to figure that out from the 
stack trace)


DaveA



More information about the Python-list mailing list