diff -r 67714c4d9725 Lib/asynchat.py --- a/Lib/asynchat.py Mon Jun 10 23:02:56 2013 -0500 +++ b/Lib/asynchat.py Tue Jun 11 15:25:02 2013 +0200 @@ -215,15 +215,12 @@ def initiate_send(self): while self.producer_fifo and self.connected: - first = self.producer_fifo[0] + first = self.producer_fifo.popleft() # handle empty string/buffer or None entry if not first: - del self.producer_fifo[0] if first is None: - ## print("first is None") self.handle_close() return - ## print("first is not None") # handle classic producer behavior obs = self.ac_out_buffer_size @@ -232,9 +229,7 @@ except TypeError: data = first.more() if data: - self.producer_fifo.appendleft(data) - else: - del self.producer_fifo[0] + self.producer_fifo.appendleft([data, first]) continue if isinstance(data, str) and self.use_encoding: @@ -249,9 +244,7 @@ if num_sent: if num_sent < len(data) or obs < len(first): - self.producer_fifo[0] = first[num_sent:] - else: - del self.producer_fifo[0] + self.producer_fifo.appendleft(first[num_sent:]) # we tried to send some actual data return