Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket module missing IPPROTO_IPV6, IPPROTO_IPV4 #51175

Closed
jaraco opened this issue Sep 16, 2009 · 20 comments
Closed

socket module missing IPPROTO_IPV6, IPPROTO_IPV4 #51175

jaraco opened this issue Sep 16, 2009 · 20 comments
Assignees
Labels
OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@jaraco
Copy link
Member

jaraco commented Sep 16, 2009

BPO 6926
Nosy @loewis, @birkenfeld, @rhettinger, @gpshead, @jaraco, @vstinner, @giampaolo, @tiran, @merwok, @briancurtin, @berkerpeksag, @mhils

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/loewis'
closed_at = <Date 2016-08-02.16:23:29.550>
created_at = <Date 2009-09-16.23:18:05.492>
labels = ['type-bug', 'library', 'OS-windows']
title = 'socket module missing IPPROTO_IPV6, IPPROTO_IPV4'
updated_at = <Date 2017-02-09.23:14:18.151>
user = 'https://github.com/jaraco'

bugs.python.org fields:

activity = <Date 2017-02-09.23:14:18.151>
actor = 'mhils'
assignee = 'loewis'
closed = True
closed_date = <Date 2016-08-02.16:23:29.550>
closer = 'berker.peksag'
components = ['Library (Lib)', 'Windows']
creation = <Date 2009-09-16.23:18:05.492>
creator = 'jaraco'
dependencies = []
files = []
hgrepos = []
issue_num = 6926
keywords = []
message_count = 20.0
messages = ['92730', '92731', '92735', '92736', '100223', '100247', '100249', '100250', '107088', '127068', '127069', '127071', '127072', '220650', '220763', '220770', '271828', '287442', '287443', '287466']
nosy_count = 14.0
nosy_names = ['loewis', 'georg.brandl', 'rhettinger', 'gregory.p.smith', 'jaraco', 'vstinner', 'giampaolo.rodola', 'christian.heimes', 'eric.araujo', 'brian.curtin', 'Steven.Hayter', 'BreamoreBoy', 'berker.peksag', 'mhils']
pr_nums = []
priority = 'high'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue6926'
versions = ['Python 3.4', 'Python 3.5']

@jaraco
Copy link
Member Author

jaraco commented Sep 16, 2009

It appears that somewhere between Python 2.5 and Python 2.6, some socket
constants were lost in Windows builds.

Python 2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket; socket.IPPROTO_IPV6
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'IPPROTO_IPV6'

Confirmed this problem on 32-bit builds and Python 3.1.1 also. I suspect
the compiler upgrade influenced this behavior.

Let me know if I can help track down the issue.

@jaraco jaraco added topic-IO OS-windows type-bug An unexpected behavior, bug, or error labels Sep 16, 2009
@jaraco
Copy link
Member Author

jaraco commented Sep 16, 2009

This comment from the MSDN docs may be relevant:

On the Microsoft Windows Software Development Kit (SDK) released for
Windows Vista and later, the organization of header files has changed
and IPPROTO_IPV6 level is defined in the Ws2def.h header file which is
automatically included in the Winsock2.h header file. The IPPROTO_IPV6
socket options are defined in the Ws2ipdef.h header file which is
automatically included in the Ws2tcpip.h header file. The Ws2def.h and
Ws2ipdef.h header files should never be used directly.

@jaraco
Copy link
Member Author

jaraco commented Sep 17, 2009

I think I found the problem.

It appears Python is compiled with

#define _WIN32_WINNT 0x0500

But IPPROTO_IPV6 (and other constants) are only defined

#if(_WIN32_WINNT >= 0x0501)

What's the proper fix for this issue?

@jaraco
Copy link
Member Author

jaraco commented Sep 17, 2009

I think a suitable test case for this issue is:

if hasattr(sys, 'getwindowsversion'):
  if sys.getwindowsversion() >= (5,1):
    assert hasattr(socket, 'IPPROTO_IPV6')

@StevenHayter
Copy link
Mannequin

StevenHayter mannequin commented Feb 28, 2010

Tried against 2.5.5, 2.6.4, 2.7a3 and 3.1.1, all seem to fail.

@gpshead
Copy link
Member

gpshead commented Mar 1, 2010

In PC/pyconfig.h we #define Py_WINVER to _WIN32_WINNT_WIN2K (0x500) for 32bit builds.

I think we should update this to _WIN32_WINNT_WINXP (0x501) for all builds, not just 64bit.

Assigning to loewis as he does our windows release builds so likely knows what the ramifications of this would be.

@loewis
Copy link
Mannequin

loewis mannequin commented Mar 1, 2010

Bumping the API level to XP might mean that we stop supporting Windows 2000; I'm not sure whether we agreed to that yet.

I'd be curious to find out why the constants were defined in Python 2.5.

@gpshead
Copy link
Member

gpshead commented Mar 1, 2010

"extended support" for windows 2000 server ends in a few months, mainstream support ended 5 years ago:

http://support.microsoft.com/lifecycle/?LN=en-us&x=8&y=9&p1=7274

That, IMNSHO, implies that python 2.7 and 3.2 should not bother supporting win2k.

Regardless, I'd imagine we can look the particular constants in question up and hard code the values when the header files don't define them for us (that is also the obvious workaround for anyone needing them in code today).

@loewis
Copy link
Mannequin

loewis mannequin commented Jun 4, 2010

Following the python-dev consensus, I have now added a warning to the 2.7 installer that this will be the last release supporting Windows 2000.

I still think that we should not bump the SDK version above 500 for 2.7. Changing the SDK level does *not just* enable new API functions and constants, it may also change the layout of structures, causing applications to break on earlier systems (see the desaster with SystemParametersInfo, bpo-1601). Bumping the version for 3.2 is fine.

@merwok
Copy link
Member

merwok commented Jan 25, 2011

Should this be fixed before the final release?

@merwok merwok added stdlib Python modules in the Lib dir and removed topic-IO labels Jan 25, 2011
@gpshead
Copy link
Member

gpshead commented Jan 25, 2011

IMNSHO it should but that would violate our release practices to do it this late in the cycle. I expect the release manager to decline.

It isn't a critical issue, the end result is that people will hard code the constants into their own code themselves since we don't have them in the library yet.

@rhettinger
Copy link
Contributor

I would consider it to be regression and bugfix that is not inappropriate to repair at this point.

@loewis
Copy link
Mannequin

loewis mannequin commented Jan 25, 2011

I would consider it to be regression and bugfix that is not inappropriate to repair at this point.

I'd also be in favor of fixing it. To reduce the risk of breaking
something, I'd only raise socketmodule to a more recent Windows API.
Of course, this, in itself, might also break something.

@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Jun 15, 2014

As XP is now out of support here are links http://legacy.python.org/dev/peps/pep-0011/#microsoft-windows http://support.microsoft.com/lifecycle/ that I hope come in useful.

@vstinner
Copy link
Member

I don't think that Windows XP is officially no more supported in Python. I would prefer an explicit mention in the PEP-11. So please don't use this argument to close an issue.

@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Jun 16, 2014

It looks as if we're talking at cross purposes. PEP-11 will not be updated any more for Windows releases, we will be following the Microsoft support life cycle. That is clearly of interest to anybody wishing to make code changes against this issue. I do not want, and did not wish to imply, that this issue should be closed.

@berkerpeksag
Copy link
Member

Py_WINVER has been updated to use 0x0600 (_WIN32_WINNT_VISTA) in 57e2549cc9a6 (bpo-23451) Since the consensus was to keep 2.7 as is I'm closing this as 'out of date'.

@mhils
Copy link
Mannequin

mhils mannequin commented Feb 9, 2017

This still seems to be an issue with the offical Python 3.6 builds on Windows 10:

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
>>> import socket
>>> socket.IPPROTO_IPV6
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'socket' has no attribute 'IPPROTO_IPV6'

@tiran
Copy link
Member

tiran commented Feb 9, 2017

The constants are defined on Linux. That means Windows does not define the constants and therefore the socket module can't export them.

This ticket is closed. If you still think it's a bug, please open a new ticket and reference this ticket.

@mhils
Copy link
Mannequin

mhils mannequin commented Feb 9, 2017

Thanks for the insanely quick feedback. I still think this is a bug, so I filed https://bugs.python.org/issue29515 with additional details. Let's continue there.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

7 participants