Message223494
The problem here is that you are trying to use sys.stdin for two different purposes: 1. as a data input source for your program using stdin redirected to a disk file; and 2. for pdb's source of debugging commands, expected to be a terminal file. By specifying "-m pdb", you are telling pdb to start an interactive debugging which it does, paused at the first statement in sample.py ("-> import sys, pdb"). It (actually the cmd standard library module which pdb uses) then tries to read stdin for command input but, because of the command line redirect (" < binary.exe"), reads the binary file instead. Note this happens before sample.py has done anything. If you just ran the command "python sample.py < binary.exe", then pdb would not be involved initially, the script would run, read the redirected file until EOF, and then invoke pdb via set_trace. But, at that point, the redirected sys.stdin is at EOF so pdb immediately exits after trying to read a command. The doc page for pdb does not specifically warn against redirecting stdin but it does document that the pdb.Pdb instance passes stdin arguments to a cmd.Cmd instance which defaults to using sys.stdin. I think that's warning enough.
There is an open pdb feature request, Issue20061, to make it more convenient to use pdb with a separate terminal window. That feature would also cover the rare use case here of having a redirected stdin with pdb. Otherwise, you need to be careful how you use stdin while using pdb. |
|
Date |
User |
Action |
Args |
2014-07-20 02:03:01 | ned.deily | set | recipients:
+ ned.deily, silverbacknet |
2014-07-20 02:03:01 | ned.deily | set | messageid: <1405821781.06.0.380195343483.issue22009@psf.upfronthosting.co.za> |
2014-07-20 02:03:00 | ned.deily | link | issue22009 messages |
2014-07-20 02:02:59 | ned.deily | create | |
|