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.IPPROTO_IPV6 undefined in Python 2.7.12 for Windows #138

Closed
nicolasrozain opened this issue Sep 28, 2016 · 6 comments
Closed

socket.IPPROTO_IPV6 undefined in Python 2.7.12 for Windows #138

nicolasrozain opened this issue Sep 28, 2016 · 6 comments

Comments

@nicolasrozain
Copy link

nicolasrozain commented Sep 28, 2016

Hi all,

In the current commit (7e807c9), the line 172 of the file waitress/server.py contains:

self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)

Thing is, IPPROTO_IPV6 is not defined in socket...

Should it be replaced by its value (41) defined in Ws2def.h, while we gently wait for Python to fix this ?
Or should IPV6 be avoided under Windows with Python 2.7 ?

Thanks for the support,

Best,
Nicolas

@digitalresistor
Copy link
Member

digitalresistor commented Sep 28, 2016

Lovely: https://bugs.python.org/issue6926

I'd accept a patch that tried to use the value from socket and if not available set it to 41 explicitly and imports it from compat, so that compat.IPPROTO_IPV6 was in Linux/Unix socket.IPPROTO_IPV6 and when not available it's hard coded.

Not a big fan, but alas we are stuck with it.

@digitalresistor
Copy link
Member

BTW, it looks like it won't ever be fixed for Python 2.7 on Windows. So waiting is not an option. I'd recommend Python 3.5 anyway. IPv6 support should work just fine on Windows, although the testing that is currently done is done on AppVeyor on Python 3.5 only.

@kedare
Copy link

kedare commented Oct 14, 2016

I get the same message with Python 3.5.2 when trying to run devpi-server:

Traceback (most recent call last):
  File "c:\runtimes\python35\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\runtimes\python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Runtimes\Python35\Scripts\devpi-server.exe\__main__.py", line 9, in <module>
  File "c:\runtimes\python35\lib\site-packages\devpi_server\main.py", line 56, in main
    return _main(pluginmanager, argv=argv)
  File "c:\runtimes\python35\lib\site-packages\devpi_server\main.py", line 119, in _main
    return xom.main()
  File "c:\runtimes\python35\lib\site-packages\devpi_server\main.py", line 229, in main
    return wsgi_run(xom, app)
  File "c:\runtimes\python35\lib\site-packages\devpi_server\main.py", line 144, in wsgi_run
    serve(app, host=host, port=port, threads=50)
  File "c:\runtimes\python35\lib\site-packages\waitress\__init__.py", line 11, in serve
    server = _server(app, **kw)
  File "c:\runtimes\python35\lib\site-packages\waitress\server.py", line 78, in create_server
    sockinfo=sockinfo)
  File "c:\runtimes\python35\lib\site-packages\waitress\server.py", line 172, in __init__
    self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
AttributeError: module 'socket' has no attribute 'IPPROTO_IPV6'

What are the workarounds to be able to use it ? I don't care of IPv6 in my case.

@digitalresistor
Copy link
Member

@kedare Make sure to set your listen and or host/port combo to something that is explicitly IPv4 (127.0.0.1:8080 for example).

This won't activate any of the IPv6 code paths.

@digitalresistor
Copy link
Member

digitalresistor commented Oct 14, 2016

Also, what version of Windows? Looking at the bug report linked, it should be activated on Windows Vista and above... and thus should be available.

Are you using the 32 bit version of Python or the 64 bit version of Python?

@digitalresistor
Copy link
Member

Could someone pull down #140 and test that patch on Windows?

clrpackages pushed a commit to clearlinux-pkgs/waitress that referenced this issue Oct 25, 2016
…1.0.1

1.0.1 (2016-10-22)
------------------

Bugfixes
~~~~~~~~

- IPv6 support on Windows was broken due to missing constants in the socket
  module. This has been resolved by setting the constants on Windows if they
  are missing. See Pylons/waitress#138

- A ValueError was raised on Windows when passing a string for the port, on
  Windows in Python 2 using service names instead of port numbers doesn't work
  with `getaddrinfo`. This has been resolved by attempting to convert the port
  number to an integer, if that fails a ValueError will be raised. See
  Pylons/waitress#139
clrpackages pushed a commit to clearlinux-pkgs/waitress that referenced this issue Jan 11, 2017
…1.0.1

1.0.1 (2016-10-22)
------------------

Bugfixes
~~~~~~~~

- IPv6 support on Windows was broken due to missing constants in the socket
  module. This has been resolved by setting the constants on Windows if they
  are missing. See Pylons/waitress#138

- A ValueError was raised on Windows when passing a string for the port, on
  Windows in Python 2 using service names instead of port numbers doesn't work
  with `getaddrinfo`. This has been resolved by attempting to convert the port
  number to an integer, if that fails a ValueError will be raised. See
  Pylons/waitress#139
clrpackages pushed a commit to clearlinux-pkgs/waitress that referenced this issue Jan 17, 2017
…1.0.1

1.0.1 (2016-10-22)
------------------

Bugfixes
~~~~~~~~

- IPv6 support on Windows was broken due to missing constants in the socket
  module. This has been resolved by setting the constants on Windows if they
  are missing. See Pylons/waitress#138

- A ValueError was raised on Windows when passing a string for the port, on
  Windows in Python 2 using service names instead of port numbers doesn't work
  with `getaddrinfo`. This has been resolved by attempting to convert the port
  number to an integer, if that fails a ValueError will be raised. See
  Pylons/waitress#139
clrpackages pushed a commit to clearlinux-pkgs/waitress that referenced this issue Feb 16, 2017
…1.0.1

1.0.1 (2016-10-22)
------------------

Bugfixes
~~~~~~~~

- IPv6 support on Windows was broken due to missing constants in the socket
  module. This has been resolved by setting the constants on Windows if they
  are missing. See Pylons/waitress#138

- A ValueError was raised on Windows when passing a string for the port, on
  Windows in Python 2 using service names instead of port numbers doesn't work
  with `getaddrinfo`. This has been resolved by attempting to convert the port
  number to an integer, if that fails a ValueError will be raised. See
  Pylons/waitress#139
clrpackages pushed a commit to clearlinux-pkgs/waitress that referenced this issue Mar 9, 2017
…1.0.1

1.0.1 (2016-10-22)
------------------

Bugfixes
~~~~~~~~

- IPv6 support on Windows was broken due to missing constants in the socket
  module. This has been resolved by setting the constants on Windows if they
  are missing. See Pylons/waitress#138

- A ValueError was raised on Windows when passing a string for the port, on
  Windows in Python 2 using service names instead of port numbers doesn't work
  with `getaddrinfo`. This has been resolved by attempting to convert the port
  number to an integer, if that fails a ValueError will be raised. See
  Pylons/waitress#139
clrpackages pushed a commit to clearlinux-pkgs/waitress that referenced this issue May 5, 2017
…1.0.1

1.0.1 (2016-10-22)
------------------

Bugfixes
~~~~~~~~

- IPv6 support on Windows was broken due to missing constants in the socket
  module. This has been resolved by setting the constants on Windows if they
  are missing. See Pylons/waitress#138

- A ValueError was raised on Windows when passing a string for the port, on
  Windows in Python 2 using service names instead of port numbers doesn't work
  with `getaddrinfo`. This has been resolved by attempting to convert the port
  number to an integer, if that fails a ValueError will be raised. See
  Pylons/waitress#139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants