Message248570
I was trying to demonstrate how testing some code is hard, and I stumbled upon this.
The following code should be debuggable when run with a bad stdout - e.g.
python foo.py > /dev/full
---
import sys
import traceback
import pdb;pdb.Pdb(stdout=sys.stderr).set_trace()
try:
print("What... is your quest?")
except:
sys.stderr.write("Exception in program.\n")
traceback.print_exc(file=sys.stderr)
---
Here is a transcript of a session with it:
---
$ python ./02.py > /dev/full
> /home/robertc/work/Presentations/reveal.js/effectsnippets/02.py(5)<module>()
-> try:
(Pdb) n
> /home/robertc/work/Presentations/reveal.js/effectsnippets/02.py(6)<module>()
-> print("What... is your quest?")
(Pdb) n
--Return--
> /home/robertc/work/Presentations/reveal.js/effectsnippets/02.py(6)<module>()->None
-> print("What... is your quest?")
(Pdb) n
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
OSError: [Errno 28] No space left on device
$ echo $?
0
---
The same thing done on stderr exits with an exit code of 0 as well. |
|
Date |
User |
Action |
Args |
2015-08-14 08:59:02 | rbcollins | set | recipients:
+ rbcollins |
2015-08-14 08:59:02 | rbcollins | set | messageid: <1439542742.23.0.792306494997.issue24864@psf.upfronthosting.co.za> |
2015-08-14 08:59:02 | rbcollins | link | issue24864 messages |
2015-08-14 08:59:01 | rbcollins | create | |
|