Message29681
Logged In: YES
user_id=1534394
I found the cause of this bug:
A libc FILE* (used by python file objects) may hold a
different file offset than the underlying OS file
descriptor. The posix version of Popen._get_handles does
not take this into account, resulting in this bug.
The following patch against svn trunk fixes the problem. I
don't have permission to attach files to this item, so I'll
have to paste the patch here:
Index: subprocess.py
===================================================================
--- subprocess.py (revision 51581)
+++ subprocess.py (working copy)
@@ -907,6 +907,12 @@
else:
# Assuming file-like object
p2cread = stdin.fileno()
+ # OS file descriptor's file offset does not
necessarily match
+ # the file offset in the file-like object,
so do an lseek:
+ try:
+ os.lseek(p2cread, stdin.tell(), 0)
+ except OSError:
+ pass # file descriptor does not support
seek/tell
if stdout is None:
pass
@@ -917,6 +923,12 @@
else:
# Assuming file-like object
c2pwrite = stdout.fileno()
+ # OS file descriptor's file offset does not
necessarily match
+ # the file offset in the file-like object,
so do an lseek:
+ try:
+ os.lseek(c2pwrite, stdout.tell(), 0)
+ except OSError:
+ pass # file descriptor does not support
seek/tell
if stderr is None:
pass
@@ -929,6 +941,12 @@
else:
# Assuming file-like object
errwrite = stderr.fileno()
+ # OS file descriptor's file offset does not
necessarily match
+ # the file offset in the file-like object,
so do an lseek:
+ try:
+ os.lseek(errwrite, stderr.tell(), 0)
+ except OSError:
+ pass # file descriptor does not support
seek/tell
return (p2cread, p2cwrite,
c2pread, c2pwrite,
|
|
Date |
User |
Action |
Args |
2007-08-23 14:42:22 | admin | link | issue1546442 messages |
2007-08-23 14:42:22 | admin | create | |
|