Message1713
The second part of this bug was related to exceptions.
The error handling in httplib is essentially cpython specific. For example, when the connection to the server had been closed, it would be detected with a try .. except, catching socket.error. But the error number had to be the error number that cpython creates in this circumstance. This is the relevant code from httplib.
try:
self.sock.sendall(str)
except socket.error, v:
if v[0] == 32: # Broken pipe
self.close()
raise
As you can see, it is expecting that
A: The exception object is a tuple
B: That the first item in that tuple is the integer 32, which is the error number of "Broken Pipe".
I have now mapped the underlying java exception so that it maps to the same error number as cpython, so the above code will actually work on jython now.
It is also important to note that the httplib shipped with jython 2.1 broke in the circumstances described in this bug, i.e. this bug has always existed on jython before now. On jython 2.1, the sequence went like this
1. The first read would complete, the FileWrapper would be closed, thus causing the underlying socket to also be closed.
2. The auto_open flag was true on httplib.HTTPConnection
3. Which meant that httplib would attempt to send on the socket anyway, hoping to catch the exception if anything went wrong.
4. But the error handling, described above, expected exceptions to (int, string) tuples, not java exceptions, so attempting to get the error number failed, as you can see from this transcript of running the httplib example on jython 2.1
C:\httplibBug>jython21 closesConnectionBug.py
200 OK
Traceback (innermost last):
File "closesConnectionBug.py", line 7, in ?
File "C:\jython21\Lib\httplib.py", line 508, in request
File "C:\jython21\Lib\httplib.py", line 517, in _send_reques
File "C:\jython21\Lib\httplib.py", line 437, in putrequest
File "C:\jython21\Lib\httplib.py", line 393, in send
AttributeError: __getitem__
C:\httplibBug>
So, in summary, yes this was a bug, but it's a bug that's been in jython forever, and only now is it possible to solve the bug. |
|
Date |
User |
Action |
Args |
2008-02-20 17:17:53 | admin | link | issue1751963 messages |
2008-02-20 17:17:53 | admin | create | |
|