Mailing List Archive

How to read stdin while debuggingin PythonWin
I may be overlooking something obvious...

I'm debugging a script in PythonWin's debugger. I get to the statement
"answer = sys.stdin.read()" and the program stops as expected; but where to I
provide the input?!

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
How to read stdin while debuggingin PythonWin [ In reply to ]
he he - this is broken. Pythonwin does not provide a valid stdin (like it
does for stdout and stderr).

However, if you use input or raw_input, a dialog will be displayed.

Im not sure why this would be different under the debugger, but when I try
that from the Pythonwin window I get:
>>> sys.stdin.read()
Traceback (innermost last):
File "<interactive input>", line 0, in ?
IOError: [Errno 9] Bad file descriptor
>>>

Which is what I expect.

Mark.
How to read stdin while debuggingin PythonWin [ In reply to ]
>
> Im not sure why this would be different under the debugger, but when I try
> that from the Pythonwin window I get:
> >>> sys.stdin.read()
> Traceback (innermost last):
> File "<interactive input>", line 0, in ?
> IOError: [Errno 9] Bad file descriptor
> >>>
>

This is exectly what I observed when aborting the debug process. Any plans to
correct this and provide a place for stdin under the debugger.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
How to read stdin while debuggingin PythonWin [ In reply to ]
cmedcoff@my-dejanews.com wrote in message
<7gcfe5$qin$1@nnrp1.dejanews.com>...

>This is exectly what I observed when aborting the debug process. Any plans
to
>correct this and provide a place for stdin under the debugger.

Not really - I can't think of how it could possibly be useful. Of course, I
would be willing to accept patches :-)

Mark.
How to read stdin while debuggingin PythonWin [ In reply to ]
cmedcoff@my-dejanews.com writes:

> > Im not sure why this would be different under the debugger, but when I try
> > that from the Pythonwin window I get:
> > >>> sys.stdin.read()
> > Traceback (innermost last):
> > File "<interactive input>", line 0, in ?
> > IOError: [Errno 9] Bad file descriptor

> This is exectly what I observed when aborting the debug process.
> Any plans to correct this and provide a place for stdin under the
> debugger.

Mark may not have such plans for PythonWin, but IDLE does fully
support sys.stdin, whether or not in the IDLE debugger, in a way very
similar to using the command line python.exe.

At the moment, IDLE's debugger is not as smooth as Mark's, but it's
got your basic step and view locals/globals/source functionality.
Breakpoints seem to be broken on Windows (something to do with
pathname syntax I'm sure).

(IDLE is a new Python program development environment; IDLE 0.4 comes
with Python 1.5.2. It requires Tcl/Tk, which (on Windows) also comes
with Python 1.5.2.)

--Guido van Rossum (home page: http://www.python.org/~guido/)
How to read stdin while debuggingin PythonWin [ In reply to ]
Guido van Rossum wrote in message <5lr9p1a2qg.fsf@eric.cnri.reston.va.us>...
>cmedcoff@my-dejanews.com writes:
>
>> > Im not sure why this would be different under the debugger, but when I
try
>> > that from the Pythonwin window I get:
>> > >>> sys.stdin.read()
>> > Traceback (innermost last):
>> > File "<interactive input>", line 0, in ?
>> > IOError: [Errno 9] Bad file descriptor
>
>> This is exectly what I observed when aborting the debug process.
>> Any plans to correct this and provide a place for stdin under the
>> debugger.
>
>Mark may not have such plans for PythonWin, but IDLE does fully
>support sys.stdin, whether or not in the IDLE debugger, in a way very
>similar to using the command line python.exe.

he he - I better make Pythonwin support it.

I should clarify: If you invoke the Pythonwin debugger from a script
running under python.exe or pythonw.exe, then sys.stdin should work fine. I
definately need to know if this is not true.

Pythonwin.exe however does not setup a valid sys.stdin. Anything running
under that environment wont work with sys.stdin. The Pythonwin debugger
should be irrelevant to this.

>Breakpoints seem to be broken on Windows (something to do with
>pathname syntax I'm sure).

I recall jumping those hoops myself. Cant recall what the changes are, but
I intend examining IDLE in detail soon...

Mark.