I'm trying to debug a Python CLI I wrote that can take its arguments from stdin. A simple test case would have the output of
echo "test" | python mytool.py
be equivalent to the output of
python mytool.py test
I'd like to debug some issues with this tool, so I tried to run this:
echo "test" | pdb mytool.py
But I get this output, then pdb exits:
> /path/to/mytool.py(5)<module>()
-> '''
(Pdb) *** NameError: name 'test' is not defined
(Pdb)
The same thing occurs when I add -m python
to the shebang, and if I run pdb.set_trace()
inside the script.
What's going on here?