Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111899
| From | Malcolm Greene <python@bdurham.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Possible to capture cgitb style output in a try/except section? |
| Date | 2016-07-26 11:52 -0400 |
| Message-ID | <mailman.131.1469548376.22221.python-list@python.org> (permalink) |
| References | <1469527864.2996118.676987281.0EE8893F@webmail.messagingengine.com> <nn7qm9$uh2$1@ger.gmane.org> <1469548367.1451657.677295577.18F0D7FD@webmail.messagingengine.com> |
Hi Steven and Peter, Steven: Interestingly (oddly???) enough, the output captured by hooking the cgitb handler on my system appears to be shorter than the default cgitb output. You can see this yourself via this tiny script: import cgitb cgitb.enable(format='text') x = 1/0 The solution I came up with (Python 3.5.1) was to use your StringIO technique with the Hook's 'file=' parameter. import io cgitb_buffer = io.StringIO() cgitb.Hook(file=cgitb_buffer, format='text) return cgitb_buffer.getvalue() Peter: Your output was helpful in seeing the difference I mentioned above. Thank you both for your help! Malcolm
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Possible to capture cgitb style output in a try/except section? Malcolm Greene <python@bdurham.com> - 2016-07-26 11:52 -0400
csiph-web