summaryrefslogtreecommitdiff
path: root/Lib/asynchat.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asynchat.py')
-rw-r--r--Lib/asynchat.py25
1 files changed, 5 insertions, 20 deletions
diff --git a/Lib/asynchat.py b/Lib/asynchat.py
index 65585129ce..eea3418762 100644
--- a/Lib/asynchat.py
+++ b/Lib/asynchat.py
@@ -49,18 +49,6 @@ import socket
import asyncore
from collections import deque
-def buffer(obj, start=None, stop=None):
- # if memoryview objects gain slicing semantics,
- # this function will change for the better
- # memoryview used for the TypeError
- memoryview(obj)
- if start == None:
- start = 0
- if stop == None:
- stop = len(obj)
- x = obj[start:stop]
- ## print("buffer type is: %s"%(type(x),))
- return x
class async_chat (asyncore.dispatcher):
"""This is an abstract class. You must derive from this class, and add
@@ -75,18 +63,15 @@ class async_chat (asyncore.dispatcher):
# sign of an application bug that we don't want to pass silently
use_encoding = 0
- encoding = 'latin1'
+ encoding = 'latin-1'
def __init__ (self, sock=None, map=None):
# for string terminator matching
self.ac_in_buffer = b''
- # we use a list here rather than cStringIO for a few reasons...
- # del lst[:] is faster than sio.truncate(0)
- # lst = [] is faster than sio.truncate(0)
- # cStringIO will be gaining unicode support in py3k, which
- # will negatively affect the performance of bytes compared to
- # a ''.join() equivalent
+ # we use a list here rather than io.BytesIO for a few reasons...
+ # del lst[:] is faster than bio.truncate(0)
+ # lst = [] is faster than bio.truncate(0)
self.incoming = []
# we toss the use of the "simple producer" and replace it with
@@ -240,7 +225,7 @@ class async_chat (asyncore.dispatcher):
# handle classic producer behavior
obs = self.ac_out_buffer_size
try:
- data = buffer(first, 0, obs)
+ data = first[:obs]
except TypeError:
data = first.more()
if data: