bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS, Python's subprocess.Ppen() and STDOUT redirection


From: Michał Górny
Subject: CVS, Python's subprocess.Ppen() and STDOUT redirection
Date: Tue, 24 Aug 2010 22:54:52 +0200

Hello,

I'm trying to get CVS support integrated into my Python script,
and I ran into a serious problem.

The Python script calls various VCSes using subprocess.Popen(). As
STDOUT of the script is supposed to be piped onto another program, I
redirect STDOUT to STDERR when calling the VCSes.

While for most VCSes that works fine, CVS has real problems with
the way Python redirects fds. The 'cvs login' command only outputs
the 'Logging in...' message, and 'cvs up' doesn't output anything. Even
if I use '-tttt', they don't show any output and return with exit code
1.

I guess that's because CVS is trying to close STDOUT. In this
particular case, this causes it to close STDERR as well. I've
reproduced the problem with a simple test program:

#v+
#include <stdio.h>

int main(void) {
    fprintf(stdout, "foo\n");
    fclose(stdout);
    fprintf(stderr, "bar\n");
}
#v-

As I've expected, calling it with Popen(..., stdout=sys.stderr) causes
only 'foo' to be output.

I'm not sure if the problem is rather in CVS or Python, but I
personally think it's not a good idea to close STDOUT anyway.

-- 
Best regards,
Michał Górny

<http://mgorny.alt.pl>
<xmpp:address@hidden>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]