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:[email protected]>

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Bug-cvs mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/bug-cvs

Reply via email to