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 rbcollins
Recipients rbcollins
Date 2015-08-14.08:59:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439542742.23.0.792306494997.issue24864@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-08-14 08:59:02rbcollinssetrecipients: + rbcollins
2015-08-14 08:59:02rbcollinssetmessageid: <1439542742.23.0.792306494997.issue24864@psf.upfronthosting.co.za>
2015-08-14 08:59:02rbcollinslinkissue24864 messages
2015-08-14 08:59:01rbcollinscreate