r75134 - in python/trunk: Lib/httplib.py Lib/test/test_httplib.py Misc/ACKS Misc/NEWS
![](https://secure.gravatar.com/avatar/8ac615df352a970211b0e3d94a307c6d.jpg?s=120&d=mm&r=g)
Author: antoine.pitrou Date: Tue Sep 29 19:48:18 2009 New Revision: 75134 Log: Issue #6790: Make it possible again to pass an `array.array` to `httplib.HTTPConnection.send`. Patch by Kirk McDonald. Modified: python/trunk/Lib/httplib.py python/trunk/Lib/test/test_httplib.py python/trunk/Misc/ACKS python/trunk/Misc/NEWS Modified: python/trunk/Lib/httplib.py ============================================================================== --- python/trunk/Lib/httplib.py (original) +++ python/trunk/Lib/httplib.py Tue Sep 29 19:48:18 2009 @@ -66,6 +66,7 @@ Req-sent-unread-response _CS_REQ_SENT <response_class> """ +from array import array import socket from sys import py3kwarning from urlparse import urlsplit @@ -747,7 +748,7 @@ print "send:", repr(str) try: blocksize=8192 - if hasattr(str,'read') : + if hasattr(str,'read') and not isinstance(str, array): if self.debuglevel > 0: print "sendIng a read()able" data=str.read(blocksize) while data: Modified: python/trunk/Lib/test/test_httplib.py ============================================================================== --- python/trunk/Lib/test/test_httplib.py (original) +++ python/trunk/Lib/test/test_httplib.py Tue Sep 29 19:48:18 2009 @@ -1,3 +1,4 @@ +import array import httplib import StringIO import socket @@ -15,7 +16,7 @@ self.data = '' def sendall(self, data): - self.data += data + self.data += ''.join(data) def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': @@ -162,6 +163,20 @@ conn.request('GET', '/foo', body) self.assertTrue(sock.data.startswith(expected)) + def test_send(self): + expected = 'this is a test this is only a test' + conn = httplib.HTTPConnection('example.com') + sock = FakeSocket(None) + conn.sock = sock + conn.send(expected) + self.assertEquals(expected, sock.data) + sock.data = '' + conn.send(array.array('c', expected)) + self.assertEquals(expected, sock.data) + sock.data = '' + conn.send(StringIO.StringIO(expected)) + self.assertEquals(expected, sock.data) + def test_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Tue Sep 29 19:48:18 2009 @@ -477,6 +477,7 @@ Graham Matthews Dieter Maurer Arnaud Mazin +Kirk McDonald Chris McDonough Greg McFarlane Alan McIntyre Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 29 19:48:18 2009 @@ -383,6 +383,9 @@ Library ------- +- Issue #6790: Make it possible again to pass an `array.array` to + `httplib.HTTPConnection.send`. Patch by Kirk McDonald. + - Issue #6236, #6348: Fix various failures in the `io` module under AIX and other platforms, when using a non-gcc compiler. Patch by egreen.
participants (1)
-
antoine.pitrou