[Python-Dev] Pervasive socket failures on Windows (original) (raw)

Tim Peters tim.peters at gmail.com
Sat Feb 11 23:11:20 CET 2006


[Martin v. Löwis]

For the moment, I have committed Tim's original proposal.

Thank you! I checked, and that fixed all the test failures I was seeing on Windows.

Moving the macro into pyport.h could be done in addition. That should be done only if selectmodule is also adjusted; this currently tests for MSCVER.

It's a nice illustration of why platform-dependent code sprayed across modules sucks, too. Why _MSC_VER instead of MS_WINDOWS? What's the difference, exactly? Who knows?

I see that selectmodule.c has this comment near the top:

Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything

= 0.

but there doesn't appear to be any code matching that comment in that module -- unless on BeOS _MSC_VER is defined. Beats me whether it is, but doubt it.

The code in selectmodule when _MSC_VER is not defined complains if a socket fd is >= FD_SETSIZE or is < 0. But the new code in socketmodule on non-Windows boxes is happy with negative fds, saying "fine" whenever fd < FD_SETSIZE. Is that right or wrong?

"The answer" isn't so important to me as that this kind of crap always happens when platform-specific logic ends up getting defined in multiple modules. Much better to define macros to hide this junk, exactly once; pyport.h is the natural place for it.



More information about the Python-Dev mailing list