Hi,

when testing sage 3.0.5 using py.test, sage fails to import, because
it's using input (?) stream's write and flush methods:

    def __init__(self,stream,fallback):
        if not hasattr(stream,'write') or not hasattr(stream,'flush'):
            stream = fallback
        self.stream = stream
E       self._swrite = stream.write
>       AttributeError: DontReadFromInput instance has no attribute 'write'

[/home/ondra/ext/sage/local/lib/python2.5/site-packages/IPython/genutils.py:54]
________________________________________________________________________________


Full traceback is here:

http://paste.debian.net/11644

Not sure if this is a bug in Sage or py.test, but nevertheless, the
following patch fixes the problem:

--- /tmp/genutils.py    2008-07-19 20:50:56.000000000 +0200
+++ /home/ondra/ext/sage/local/lib/python2.5/site-packages/IPython/genutils.py  
2008-07-19
21:00:16.743189357 +0200
@@ -51,8 +51,8 @@
         if not hasattr(stream,'write') or not hasattr(stream,'flush'):
             stream = fallback
         self.stream = stream
-        self._swrite = stream.write
-        self.flush = stream.flush
+        #self._swrite = stream.write
+        #self.flush = stream.flush

     def write(self,data):
         try:


Another way to fix it is to put these lines:

import sys
sys.stdin.write = 1
sys.stdin.flush = 1

into a testfile. That's what I am using now. What py.test does is that
it sets sys.stdin to this class:

class DontReadFromInput:
    """Temporary stub class.  Ideally when stdin is accessed, the
    capturing should be turned off, with possibly all data captured
    so far sent to the screen.  This should be configurable, though,
    because in automated test runs it is better to crash than
    hang indefinitely.
    """
    def read(self, *args):
        raise IOError("reading from stdin while output is captured")
    readline = read
    readlines = read
    __iter__ = read


But I don't understand why ipython wants to write to stdin...

Ondrej

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to