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) *  |
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) *  |
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) *  |
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) *  |
Date: 2009-09-29 10:07 |
-python2.6.diff is ok, can you commit to trunk and then merge? |
|
|
msg93315 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2009-09-29 19:03 |
Committed in r75134, r75135, r75137, r75142. Thanks! |
|
|