This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ned.deily
Recipients ned.deily, silverbacknet
Date 2014-07-20.02:02:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405821781.06.0.380195343483.issue22009@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-07-20 02:03:01ned.deilysetrecipients: + ned.deily, silverbacknet
2014-07-20 02:03:01ned.deilysetmessageid: <1405821781.06.0.380195343483.issue22009@psf.upfronthosting.co.za>
2014-07-20 02:03:00ned.deilylinkissue22009 messages
2014-07-20 02:02:59ned.deilycreate