This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_subprocess fails on cygwin
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jlt63 Nosy List: aimacintyre, astrand, jlt63, tebeka
Priority: normal Keywords:

Created on 2004-11-23 08:34 by tebeka, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
foo.py astrand, 2004-12-05 15:38 Example that illustrates the problem
cygwinpipe.c astrand, 2004-12-11 08:51 Small C example that shows the bug
Messages (7)
msg23261 - (view) Author: Miki Tebeka (tebeka) * Date: 2004-11-23 08:34
[10:29] $python -V
Python 2.4c1
[10:30] $
[10:31] $
[10:31] $python -c 'from test.test_subprocess import
test_main; test_main()' -v
test_args_string (test.test_subprocess.ProcessTestCase)
... ok
test_call_kwargs (test.test_subprocess.ProcessTestCase)
... ok
test_call_seq (test.test_subprocess.ProcessTestCase) ... ok
test_call_string (test.test_subprocess.ProcessTestCase)
... ok
test_communicate (test.test_subprocess.ProcessTestCase)
... ok
test_communicate_pipe_buf
(test.test_subprocess.ProcessTestCase) ... ok
test_communicate_returns
(test.test_subprocess.ProcessTestCase) ... ok
test_cwd (test.test_subprocess.ProcessTestCase) ... ok
test_env (test.test_subprocess.ProcessTestCase) ... ok
test_exceptions (test.test_subprocess.ProcessTestCase)
... ok
test_executable (test.test_subprocess.ProcessTestCase)
... ok
test_invalid_args
(test.test_subprocess.ProcessTestCase) ... ok
test_list2cmdline
(test.test_subprocess.ProcessTestCase) ... ok
test_no_leaking (test.test_subprocess.ProcessTestCase)
... ok
test_poll (test.test_subprocess.ProcessTestCase) ... ok
test_preexec (test.test_subprocess.ProcessTestCase) ... ok
test_run_abort (test.test_subprocess.ProcessTestCase)
... ok
test_shell_sequence
(test.test_subprocess.ProcessTestCase) ... ok
test_shell_string
(test.test_subprocess.ProcessTestCase) ... ok
test_stderr_filedes
(test.test_subprocess.ProcessTestCase) ... ok
test_stderr_fileobj
(test.test_subprocess.ProcessTestCase) ... ok
test_stderr_none (test.test_subprocess.ProcessTestCase)
... ok
test_stderr_pipe (test.test_subprocess.ProcessTestCase)
... ok
test_stdin_filedes
(test.test_subprocess.ProcessTestCase) ... ok
test_stdin_fileobj
(test.test_subprocess.ProcessTestCase) ... ok
test_stdin_none (test.test_subprocess.ProcessTestCase)
... ok
test_stdin_pipe (test.test_subprocess.ProcessTestCase)
... ok
test_stdout_filedes
(test.test_subprocess.ProcessTestCase) ... ok
test_stdout_fileobj
(test.test_subprocess.ProcessTestCase) ... ok
test_stdout_none (test.test_subprocess.ProcessTestCase)
...     this bit of output is from a test of stdout in
a different process ...
ok
test_stdout_pipe (test.test_subprocess.ProcessTestCase)
... ok
test_stdout_stderr_file
(test.test_subprocess.ProcessTestCase) ... ok
test_stdout_stderr_pipe
(test.test_subprocess.ProcessTestCase) ... FAIL
test_universal_newlines
(test.test_subprocess.ProcessTestCase) ... FAIL
test_universal_newlines_communicate
(test.test_subprocess.ProcessTestCase) ... ok
test_wait (test.test_subprocess.ProcessTestCase) ... ok
test_writes_before_communicate
(test.test_subprocess.ProcessTestCase) ... ok

======================================================================
FAIL: test_stdout_stderr_pipe
(test.test_subprocess.ProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/test/test_subprocess.py",
line 191, in test_stdout_stderr_pipe
    self.assertEqual(stripped, "appleorange")
AssertionError: 'apple' != 'appleorange'

======================================================================
FAIL: test_universal_newlines
(test.test_subprocess.ProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/test/test_subprocess.py",
line 312, in test_universal_newlines
    "line1\nline2\nline3\nline4\nline5\nline6")
AssertionError: 'line1\n' !=
'line1\nline2\nline3\nline4\nline5\nline6'

----------------------------------------------------------------------
Ran 37 tests in 109.478s

FAILED (failures=2)
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "/usr/lib/python2.4/test/test_subprocess.py",
line 548, in test_main
    test_support.run_unittest(ProcessTestCase)
  File "/usr/lib/python2.4/test/test_support.py", line
290, in run_unittest
    run_suite(suite, testclass)
  File "/usr/lib/python2.4/test/test_support.py", line
274, in run_suite
    raise TestFailed(msg)
test.test_support.TestFailed: errors occurred in
test.test_subprocess.ProcessTestCase
msg23262 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-12-05 14:43
Logged In: YES 
user_id=344921

This seems to be a Cygwin bug: p.stdout.read() only returns
a partial result. Another p.stdout.read() is necessary to
retrieve all data. fileobject.read should return all data,
though. It doesn't, because fread() is behaving strange: It
returns a short read, but neither feof() nor ferror() is
set. This is wrong:

"Upon  successful  completion, fread() shall return the
number of elements successfully read which is less than
nitems only if a read error or end-of-file is encountered."

One strange thing is that this only happens if close-on-exec
is used for the error pipe. Perhaps a race condition. 
msg23263 - (view) Author: Andrew I MacIntyre (aimacintyre) * (Python triager) Date: 2004-12-12 09:05
Logged In: YES 
user_id=250749

As a Cygwin specific issue, I'd suggest reassigning the bug
to Jason Tishler (jlt63) who maintains the Cygwin port.
msg23264 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-12-12 09:36
Logged In: YES 
user_id=344921

Reassigned to jlt63. 

See http://cygwin.com/ml/cygwin/2004-12/msg00135.html and
http://sources.redhat.com/ml/newlib/2004/msg00559.html for
details. 
msg23265 - (view) Author: Jason Tishler (jlt63) * (Python triager) Date: 2004-12-13 19:04
Logged In: YES 
user_id=86216

I will look into this problem and why test_shutil failed until
someone hacked the regression test so it passes under
Cygwin now.

Unfortunately, it may be a while before I find adequate time
to debug this problem. ;,(

Peter,

Since you have already devised a test case, would you be
willing to go to the next step and fire up gdb? Any help is
greatly appreciated. Thanks.
msg23266 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-12-13 19:21
Logged In: YES 
user_id=344921

I don't think gdb is necessary: we already know the problem:
newlib doesn't loop around read() until all data is read.
Some Cygwin people seems to think that this is not a bug,
but I don't agree. 
msg23267 - (view) Author: Jason Tishler (jlt63) * (Python triager) Date: 2004-12-14 13:35
Logged In: YES 
user_id=86216

I'm happy to report the following newlib patch:

http://sources.redhat.com/ml/newlib-cvs/2004-
q4/msg00031.html

fixes the report problem and test_subprocess passes under
Cygwin CVS as of 20041214.

test_subprocess should pass under Cygwin 1.5.13 (when
released).

Peter, thanks for helping to solve this problem. I really
appreciate your help *and* perseverance. :,)
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41211
2004-11-23 08:34:13tebekacreate