On Thu, May 6, 2010 at 5:59 AM, Sarah Mount <mount.sa...@gmail.com> wrote: > On 5 May 2010 10:17, Carl Banks <pavlovevide...@gmail.com> wrote: >> On May 2, 11:06 am, Sarah Mount <mount.sa...@gmail.com> wrote: >>> This is a bit of an odd question, but is there any way for a Python >>> debugger to suppress I/O generated by the program which is being >>> debugged? I guess an "obvious" thing to do would be to replace core >>> parts of the standard library and change any relevant imports in the >>> locals and globals dicts to fake ones which don't generate I/O, but >>> this seems brittle as the standard library will change over time. Is >>> it possible to modify the byte-compiled code in each stack frame? Or >>> is there a simpler way to do this? >> >> It's not foolproof but you could try to reassign sys.stdout and >> sys.stderr to a bit bucket ("sys.stdout = open(os.devull)"), then >> invoke the debugger with stdout set to sys._stdout (the actual >> stdout). You'll have to create the Pdb() by hand since the built-in >> convience functions don't do it. Check the file pdb.py for details. >> > > Thanks Carl. I had considered this, but it won't catch things like > socket communication. Hmmm.....
You could monkeypatch the socket constructors in the `socket` module to return dummies. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list