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: missing constants in socket module
Type: behavior Stage:
Components: Extension Modules Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: lemburg Nosy List: akuchling, christian.heimes, dbinger, lemburg, loewis, skip.montanaro
Priority: normal Keywords: patch

Created on 2007-11-28 21:07 by dbinger, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (13)
msg57921 - (view) Author: David Binger (dbinger) Date: 2007-11-28 21:07
TCP_NODELAY and some constants are not present in the socket module.
I think maybe "#include <netinet/tcp.h>" should appear somewhere, 
perhaps at the top of socketmodule.c?
(This is on OS X 10.5.1 with py3k revision 59215).
msg57975 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-30 11:28
On my Linux box (Ubuntu 7.10, i386, 2.6.22) the TCP_* constants are also
missing. This patch solves the bug.

Index: Modules/socketmodule.h
===================================================================
--- Modules/socketmodule.h      (revision 59228)
+++ Modules/socketmodule.h      (working copy)
@@ -8,9 +8,7 @@
 #   include <sys/socket.h>
 # endif
 # include <netinet/in.h>
-# if defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))
-#  include <netinet/tcp.h>
-# endif
+# include <netinet/tcp.h>

 #else /* MS_WINDOWS */
 #if _MSC_VER >= 1300
msg57977 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-30 11:31
I've added Lemburg, Löwis and Skip to the nosy list. svn ann shows their
names frequently.
msg57978 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2007-11-30 11:49
While the patch looks right (can't say for sure whether netinet/tcp.h is
always available), I think the approach itself of adding these constants
to the socket module is wrong.

Instead of adding these constants to the socket module, they should go
into a new TCP.py module and get generated by the h2py script much like
IN.py is already for each platform.
msg58022 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-11-30 22:47
I disagree. h2py is much too unreliable, and should be phased out over time.
msg58024 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2007-11-30 22:56
If you think we need a better tool, that's a different story, but not an
argument for cluttering up the socket module with a more or less
complete list of C constants.

It's much easier to maintain this outside the socket module in a
separate, platform specific module. This also has the advantage of being
able to see whether a constant is available on a specific platform or
not and also provides access to platform specific constants that would
otherwise not be available.

BTW: Can you point me to a bug report where an h2py generated IN.py has
failed to include important symbols ?
msg58025 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2007-11-30 22:57
Doesn't this bug report also refer to Python 2.5 and 2.6 ?
msg58030 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-30 23:20
On my system (Ubuntu 7.10, i386, Kernel 2.6.20) the _socket modules of
Python 2.5 and trunk have the TCP_ constants.
msg58032 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2007-11-30 23:29
Interesting. It appears as if r57142 caused this change.

Before:

# if !(defined(__BEOS__) || defined(__CYGWIN__) || (defined(PYOS_OS2) &&
defined(PYCC_VACPP)))

After:

# if defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))

That change obviously changed semantics :-)
msg58033 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-30 23:35
Marc-Andre Lemburg wrote:
> Marc-Andre Lemburg added the comment:
> 
> Interesting. It appears as if r57142 caused this change.

Good work, Marc-Andre! I've restored the old semantic in r57142.

Christian
msg58035 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2007-12-01 00:28
mal> Interesting. It appears as if r57142 caused this change.

How do I get a diff of the change in r57142?  In particular, is it something
I did?  I was working on deleting BeOS support (and support for other
minority platforms) awhile ago.  I don't recall whether I finally finished
that or if this was something someone else did.

Skip
msg58036 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2007-12-01 01:08
mal> Interesting. It appears as if r57142 caused this change.

    Skip> How do I get a diff of the change in r57142?

Okay, I got that diff.  The change was from my BeOS cleaning.  While adding
back in that ifdef certain restores the desired behavior, I think it's the
wrong test to perform.  Something less platform-specific should be used,
though I'm not sure what the correct test should be.

Skip
msg99826 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2010-02-22 20:32
The original problem has been fixed since 2007.  Improving the #if condition doesn't seem very important to anyone, so I'll just close this bug.
History
Date User Action Args
2022-04-11 14:56:28adminsetgithub: 45855
2010-02-22 20:32:53akuchlingsetstatus: open -> closed

nosy: + akuchling
messages: + msg99826

resolution: fixed
2008-01-06 22:29:44adminsetkeywords: - py3k
versions: Python 3.0
2007-12-01 01:08:36skip.montanarosetmessages: + msg58036
2007-12-01 00:28:26skip.montanarosetmessages: + msg58035
2007-11-30 23:35:35christian.heimessetmessages: + msg58033
2007-11-30 23:29:57lemburgsetmessages: + msg58032
2007-11-30 23:20:37christian.heimessetmessages: + msg58030
2007-11-30 22:57:05lemburgsetmessages: + msg58025
2007-11-30 22:56:10lemburgsetmessages: + msg58024
2007-11-30 22:47:12loewissetmessages: + msg58022
2007-11-30 11:49:52lemburgsetmessages: + msg57978
2007-11-30 11:31:27christian.heimessetnosy: + loewis, skip.montanaro
messages: + msg57977
2007-11-30 11:28:46christian.heimessetnosy: + christian.heimes, lemburg
messages: + msg57975
priority: normal
assignee: lemburg
components: + Extension Modules, - Library (Lib), macOS
keywords: + py3k, patch
2007-11-28 21:07:32dbingercreate