Message10194

Author sophacles
Recipients mbakht, sophacles, zyasoft
Date 2015-09-01.19:35:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1441136120.12.0.217591429931.issue2374@psf.upfronthosting.co.za>
In-reply-to
Content
This bug is affecting me as well, so I did some more digging - It turns out there are a couple of problems here... (which maybe are getting conflated somehow?)

In the constructor of socket, CPython doesn't allow None for proto. It requires an integer. 

In setsockopt after creating a socket with proto = 0. The pika module mentioned sets TCP_NODELAY after creating a socket with proto = 0. In CPython this works, but in jython it does not. 

Here is the output of a Jython session (note the bare value 6 is the value on my system for socket.SOL_TCP which is not defined in Jython a third incompatibility)

>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, None)
>>> s.setsockopt(6, socket.TCP_NODELAY, 1)
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
>>> s.setsockopt(6, socket.TCP_NODELAY, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/_socket.py", line 1367, in meth
    return getattr(self._sock,name)(*args)
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/_socket.py", line 357, in handle_exception
    return method_or_function(*args, **kwargs)
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/_socket.py", line 357, in handle_exception
    return method_or_function(*args, **kwargs)
  File "/usr/local/Cellar/jython/2.7.0/libexec/Lib/_socket.py", line 1204, in setsockopt
    raise error(errno.ENOPROTOOPT, "Protocol not available")
_socket.error: [Errno 42] Protocol not available

In CPython this is the output:

>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 187, in __init__
    _sock = _realsocket(family, type, proto)
TypeError: an integer is required
>>> 
>>> 
>>> s = socket.socket(socekt.AF_INET, socket.SOCK_STREAM, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'socekt' is not defined
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
>>> s.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)


Note that in both systems, creating the socket without passing a value to the 3rd argument of the socket constructor, setsockopt works just fine. The mismatch appears to be on explicitly setting the 3rd argument to the default value.
History
Date User Action Args
2015-09-01 19:35:20sophaclessetmessageid: <1441136120.12.0.217591429931.issue2374@psf.upfronthosting.co.za>
2015-09-01 19:35:20sophaclessetrecipients: + sophacles, zyasoft, mbakht
2015-09-01 19:35:20sophacleslinkissue2374 messages
2015-09-01 19:35:19sophaclescreate