I ran across an annoyance and wondered if anyone else hit this.

I have some compiled C code wrapped with Cython that writes to
an ordinary file descriptor when the debug level is high enough.
It directly references sys.stdout and sends output there.  When
using a doctest, however, that object is replaced with _SpoofOut
that subclasses StringIO.  Thus, when executing something like the
following in a doctest:

   ...
   cdef file outFile = sys.stdout  # This fails for the spoofed output
   callDebugCodeInC(PyFile_AsFile(outFile))
   ...

It (understandably) fails on the assignment with a message:
   TypeError: Cannot convert instance to file

Ideas?  At the moment, I just forgo the convenience of turning on
that debug within doctest.

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to