<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On 28/10/2009, at 19:44 , holger krekel holger-at-merlinux.eu |py-dev + execnet-dev| wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><blockquote type="cite">Hi Holger,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I started looking into this a bit but ran into a problem when I &nbsp;<br></blockquote><blockquote type="cite">started to probe the py.io module.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I tried running the py.io examples on the website &lt;<a href="http://codespeak.net/py/dist/io.html">http://codespeak.net/py/dist/io.html</a><span class="Apple-converted-space">&nbsp;</span><br></blockquote><blockquote type="cite"><blockquote type="cite">but when I run the py.io.StdCaptureFD example, python dies on the &nbsp;<br></blockquote></blockquote><blockquote type="cite">second line:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">stakita@okum:~$ python<br></blockquote><blockquote type="cite">Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)<br></blockquote><blockquote type="cite">[GCC 4.3.3] on linux2<br></blockquote><blockquote type="cite">Type "help", "copyright", "credits" or "license" for more information.<br></blockquote><blockquote type="cite">History restored: /auto/home/stakita/.pyhistory, Max Length: 500<br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">import py, sys<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">capture = py.io.StdCaptureFD()<br></blockquote></blockquote></blockquote></blockquote><br>The redirect here happens for stdout, stderr and stdin is put to<span class="Apple-converted-space">&nbsp;</span><br>/dev/zero on the file descriptor level ...<br><br><blockquote type="cite">stakita@okum:~$<br></blockquote><br>... so the python interpreter immediately gets an EOL on stdin and dies.<span class="Apple-converted-space">&nbsp;</span><br></span></blockquote><div><br></div>So does this mean that the example is a bit broken then?</div><div><br></div><div><br></div><div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><blockquote type="cite">My guess is that an exception is being thrown, but the captured &nbsp;<br></blockquote><blockquote type="cite">sys.stderr descriptor is not passing any meaningful traceback.<br></blockquote><br>you can call py.io.StdCaptureFD(err=True, in_=False,<br>out=False) and should be able to play with writing to stderr.<br><br><blockquote type="cite">I tried wrapping the call in try/except, but that didn't seem to help. &nbsp;<br></blockquote><blockquote type="cite">On the positive side, the problem appears to be quite reproducible.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Any ideas on what is going on here?<br></blockquote><br>just anoter recommendation. &nbsp;Maybe it is easiest for you to implement<span class="Apple-converted-space">&nbsp;</span><br>a "--iocapturelog=filename" option and see to send output to<br>it from the pytest_capture plugin on the py-trunk repository. &nbsp;<br>You can start experimenting by copying the pytest_capture.py<br>file somewhere into your import path and modifying it. &nbsp;Your<br>local version will override the builtin one.<br><br>HTH,<br>holger</span></blockquote><br></div><div>Thanks for the suggestion, and here is a first pass. Attached is a modified version of pytest_capture.py from the 1.0.2 release.<div><br></div><div>In this file, I just push the options into the CaptureManager so that the command line args are available. This does mean that the config file options stuff is not hooked up, but at least it works from the command line at the moment.<div><br></div><div>Additional plugin command line options are:</div><div><div>&nbsp;&nbsp; &nbsp;--log-file &lt;filename&gt;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;When used with the two capture options ('fd' and 'sys') this will enable pushing the stdout and stderr writes to the specified file.</div><div>&nbsp;&nbsp; &nbsp;--append-log</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;This allows appending to the file as opposed to the default clobber behaviour.</div><div><br></div><div>Does this fit with your model of how the plugin should be structured?</div><div><br></div><div>Regards,</div><div><br></div><div>Simon</div><div><br></div></div></div></div></body></html>