Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111899 > unrolled thread
| Started by | Malcolm Greene <python@bdurham.com> |
|---|---|
| First post | 2016-07-26 11:52 -0400 |
| Last post | 2016-07-26 11:52 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Possible to capture cgitb style output in a try/except section? Malcolm Greene <python@bdurham.com> - 2016-07-26 11:52 -0400
| From | Malcolm Greene <python@bdurham.com> |
|---|---|
| Date | 2016-07-26 11:52 -0400 |
| Subject | Re: Possible to capture cgitb style output in a try/except section? |
| Message-ID | <mailman.131.1469548376.22221.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web