#9 Interact generates OSError

closed-out-of-date
nobody
None
5
2010-03-17
2006-11-03
Anonymous
No

When I run what should be a simple command:

child = pexpect.spawn('ls -al')
child.interact()

I see the following output:

total 64
drwxr-xr-x 4 dlibby ita 4096 Nov 3 11:01 .
drwxr-xr-x 7 dlibby ita 4096 Oct 6 14:58 ..
-rw-r--r-- 1 dlibby ita 8778 Nov 3 11:13 app.py
-rw-r--r-- 1 dlibby ita 14937 Nov 3 11:13 deploy.py
drwxr-xr-x 3 dlibby ita 4096 Nov 3 11:18 lib
drwxr-xr-x 7 dlibby ita 4096 Nov 3 11:09 .svn
-rw-r--r-- 1 dlibby ita 259 Nov 3 11:15 test.py
-rw-r--r-- 1 dlibby ita 5260 Nov 3 11:13 utilities.py
-rw-r--r-- 1 dlibby ita 5401 Nov 3 11:13 web.py
Traceback (most recent call last):
File "test.py", line 12, in ?
child.interact()
File "/ita/workspace_trunk/ops/bin/lib/pexpect.py",
line 1229, in interact
self.__interact_copy(escape_character,
input_filter, output_filter)
File "/ita/workspace_trunk/ops/bin/lib/pexpect.py",
line 1249, in __interact_copy
data = self.__interact_read(self.child_fd)
File "/ita/workspace_trunk/ops/bin/lib/pexpect.py",
line 1242, in __interact_read
return os.read(fd, 1000)
OSError: [Errno 5] Input/output error

I hacked together a fix to wrap __interact_read() in a
try block which will raise an EOF exception similar to
how expect works. I'd be happy to send you the code if
you are interested. All in all, exactly what I needed.
Great product.

Derek Libby
derek.libby@gmail.com

Discussion

  • Noah Spurrier
    Noah Spurrier
    2010-03-17

    This is an old bug. This doesn't happen now.

     
  • Noah Spurrier
    Noah Spurrier
    2010-03-17

    • status: open --> closed-out-of-date