[Python-Dev] PEP 0404 and VS 2010

Steve Dower Steve.Dower at microsoft.com
Mon Nov 25 22:11:26 CET 2013

Steve Dower wrote:
> The advice I've been given on FILE* is that there's probably no way to make it
> work correctly due to its internal buffering. Unfortunately, there are more
> places where this leaks through than just the APIs using them - extensions that
> call os.dup(fd), PyNumber_AsSsize_t() and pass the result to _fdopen() (for
> example, numpy) are simply going to break with mismatched fd's and there's no
> way to detect it at compile time. It's hard to tell how wide-ranging this sort
> of issue is going to be, but it certainly has the potential to break badly...

After thinking about this and looking into it, I think the breakage caused by this sort of code is so bad that we should be discouraging it. The internal buffering, especially on stdin/stdout/stderr, will wreak havoc on any extensions that use them, and code that casts fds to ints within Python will simply crash. The loss of confidence here may be irrecoverable - I don't think we should be making it easy for people to get into this situation.

We could make it opt-in for extension modules, but I think that situation is worse than the current one. The best solution is always going to be for users to install VS 2008, or at least VC9 (I'm working on making this easier, but it requires getting the attention of a lot of busy people...).

Any thoughts?


More information about the Python-Dev mailing list