Issue1119

classification
Title: socket module has no attribute SO_ERROR
Type: Severity: normal
Components: Versions: 2.2.2
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: amak Nosy List: amak, glyph
Priority: normal Keywords: twisted

Created on 2008-09-06.16:21:48 by glyph, last changed 2012-08-25.14:31:46 by amak.

Messages
msg3472 (view) Author: Glyph Lefkowitz (glyph) Date: 2008-09-06.16:21:47
Twisted wants to get the pending socket error to notify the application
when certain errors occur, but it can't:

          File
"/home/glyph/Projects/Twisted/trunk/twisted/internet/tcp.py", line 629,
in doConnect
            err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
        exceptions.AttributeError: 'module' object has no attribute
'SO_ERROR'
msg3501 (view) Author: Alan Kennedy (amak) Date: 2008-09-13.12:14:44
There are two parts to this bug.

1. The jython socket module is indeed missing the SO_ERROR option constant.
2. Java does not support the SO_ERROR option anyway.

Currrently, the jython socket module supports *all* of the limited set
of socket options available on the java platform; documented here, under
"Socket Options"; SO_ERROR is explicitly not supported.

http://wiki.python.org/jython/NewSocketModule

The current behaviour when a non-supported option is requested through
either setsockopt or getsockopt is to raise an exception.

So the resolution on this bug will be 

1. The SO_ERROR constant will be added to the jython socket module
2. But any attempt to use it in [g|s]etsockopt will result in an
exception, like so

try:
  err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
except socket.error, se:
  if se[0] == errno.ENOPROTOOPT:
    print "Socket does not support the SO_ERROR option"

I will check in this fix later today.
msg3516 (view) Author: Alan Kennedy (amak) Date: 2008-09-13.18:15:27
Fix checked into trunk and release 2.2 branch.

The socket module now has an SO_ERROR constant, so AttributeError should
no longer occur.

However, the constant has no usage on the JVM, because SO_ERROR is not
supported.

Attempts to use the constant as a parameter to getsockopt will result in
a socket.error exception, with errno == errno.ENOPROTOOPT, as occurs
with all other unsupported socket options on jython.

Thanks for submitting this bug.
msg7423 (view) Author: Alan Kennedy (amak) Date: 2012-08-25.14:31:45
Support for SO_ERROR checked in here

http://hg.python.org/jython/rev/a39725e023f2

And tidied up here

http://hg.python.org/jython/rev/6579bd02d930
History
Date User Action Args
2012-08-25 14:31:46amaksetmessages: + msg7423
2008-09-13 18:15:28amaksetstatus: open -> closed
resolution: fixed
messages: + msg3516
versions: + 2.2.2
2008-09-13 12:14:45amaksetpriority: normal
assignee: amak
messages: + msg3501
nosy: + amak
2008-09-06 16:30:44nrileysetkeywords: + twisted
2008-09-06 16:21:48glyphcreate