Title: socket module has no attribute SO_ERROR
Type: Severity: normal
Components: Versions: 2.2.2
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.

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:

"/home/glyph/Projects/Twisted/trunk/twisted/internet/", line 629,
in doConnect
            err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
        exceptions.AttributeError: 'module' object has no attribute
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.

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

  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

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

And tidied up here
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