classification
Title: httplib and array do not play together well
Type: behavior Stage: test needed
Components: Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pitrou Nosy List: KirkMcDonald, jakemcguire, pitrou, r.david.murray
Priority: normal Keywords: easy, patch

Created on 2009-08-27 21:08 by jakemcguire, last changed 2009-09-29 19:03 by pitrou. This issue is now closed.

Files
File name Uploaded Description Edit
issue6790-python2.7.diff KirkMcDonald, 2009-09-25 22:00 Remove array.array.read and .write in 2.7.
issue6790-python2.6.diff KirkMcDonald, 2009-09-29 00:24 special-case array.array, and add unittest for httplib.HTTPConnection.send
Messages (11)
msg92015 - (view) Author: Jake McGuire (jakemcguire) Date: 2009-08-27 21:08
As of Python 2.6 you can no longer pass an array to 
httplib.HTTPConnection.send.

Issue1065257 added code to httplib to attempt to determine whether a 
file-like object was passed to certain methods (e.g. send), and to 
stream the data if so.

The patch uses "hasattr(obj, 'read')" as a proxy for "is a file-like 
object".

array.array objects have a method called "read" that is almost entirely 
disanalogous to the "read" method on a file-like object.

Hilarity ensues.
msg92017 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-08-27 21:34
That method of array.array has been deprecated since 1.5.1 according to
the docs.  Too bad nobody finished the job and removed it.

Perhaps array.array could be special cased in the relevant code until
the method can actually be removed.
msg93145 - (view) Author: Kirk McDonald (KirkMcDonald) Date: 2009-09-25 21:59
Here is a patch special-casing array.array in httplib.HTTPConnection.send 
in Python 2.6.
msg93146 - (view) Author: Kirk McDonald (KirkMcDonald) Date: 2009-09-25 22:00
And here is a patch removing the array.array.read and .write methods in 
2.7.
msg93221 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-09-28 18:07
These methods don't even produce a DeprecationWarning in current 2.6, I
don't think it's ok to remove them.
As for the special casing patch, it would be better with a test.
msg93245 - (view) Author: Kirk McDonald (KirkMcDonald) Date: 2009-09-28 23:19
I have updated the patch with a unittest for httplib.HTTPConnection.send.
msg93247 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-09-28 23:54
Why do you need to give a non-empty body to the FakeSocket? 

Other than that, looks fine.
msg93248 - (view) Author: Kirk McDonald (KirkMcDonald) Date: 2009-09-28 23:59
Oh, I suppose I don't. I had simply copy and pasted those four lines from 
the previous method. That line could easily be removed.
msg93249 - (view) Author: Kirk McDonald (KirkMcDonald) Date: 2009-09-29 00:24
Remove unused 'body'.
msg93270 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-09-29 10:07
issue6790-python2.6.diff is ok, can you commit to trunk and then merge?
msg93315 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-09-29 19:03
Committed in r75134, r75135, r75137, r75142. Thanks!
History
Date User Action Args
2009-09-29 19:03:22pitrousetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg93315
2009-09-29 17:33:31pitrousetassignee: pitrou
2009-09-29 10:07:09pitrousetresolution: accepted
messages: + msg93270
2009-09-29 00:25:16KirkMcDonaldsetfiles: - issue6790-python2.6.diff
2009-09-29 00:24:39KirkMcDonaldsetfiles: + issue6790-python2.6.diff

messages: + msg93249
2009-09-28 23:59:19KirkMcDonaldsetmessages: + msg93248
2009-09-28 23:54:22pitrousetmessages: + msg93247
2009-09-28 23:19:41KirkMcDonaldsetfiles: - issue6790-python2.6.diff
2009-09-28 23:19:30KirkMcDonaldsetfiles: + issue6790-python2.6.diff

messages: + msg93245
2009-09-28 18:07:25pitrousetnosy: + pitrou
messages: + msg93221
2009-09-25 22:00:29KirkMcDonaldsetfiles: + issue6790-python2.7.diff

messages: + msg93146
2009-09-25 21:59:30KirkMcDonaldsetfiles: + issue6790-python2.6.diff

nosy: + KirkMcDonald
messages: + msg93145

keywords: + patch
2009-08-27 21:34:17r.david.murraysetpriority: normal

versions: + Python 3.1, Python 2.7, Python 3.2
keywords: + easy
nosy: + r.david.murray

messages: + msg92017
stage: test needed
2009-08-27 21:08:18jakemcguirecreate