summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2007-08-31 00:20:14 (GMT)
committerThomas Wouters <thomas@python.org>2007-08-31 00:20:14 (GMT)
commit74e68c751f148d6d41dd74d004ff19f05e244859 (patch)
tree83768a0add6224dfeb2741269b673eb2967002e7 /Lib
parent828f04ac3f0dd3b68b4dbf42a79ebb846d1de568 (diff)
downloadcpython-74e68c751f148d6d41dd74d004ff19f05e244859.zip
cpython-74e68c751f148d6d41dd74d004ff19f05e244859.tar.gz
cpython-74e68c751f148d6d41dd74d004ff19f05e244859.tar.bz2
Fix test_smtplib by munging asynchat some more.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asynchat.py11
-rw-r--r--Lib/test/test_smtplib.py4
2 files changed, 12 insertions, 3 deletions
diff --git a/Lib/asynchat.py b/Lib/asynchat.py
index 9443656..0e2457f 100644
--- a/Lib/asynchat.py
+++ b/Lib/asynchat.py
@@ -46,6 +46,7 @@ method) up to the terminator, and then control will be returned to
you - by calling your self.found_terminator() method.
"""
+import sys
import socket
import asyncore
from collections import deque
@@ -91,6 +92,8 @@ class async_chat (asyncore.dispatcher):
self.handle_error()
return
+ if isinstance(data, str):
+ data = data.encode('ascii')
self.ac_in_buffer = self.ac_in_buffer + bytes(data)
# Continue to search for self.terminator in self.ac_in_buffer,
@@ -126,6 +129,8 @@ class async_chat (asyncore.dispatcher):
# 3) end of buffer does not match any prefix:
# collect data
terminator_len = len(terminator)
+ if isinstance(terminator, str):
+ terminator = terminator.encode('ascii')
index = self.ac_in_buffer.find(terminator)
if index != -1:
# we found the terminator
@@ -195,11 +200,15 @@ class async_chat (asyncore.dispatcher):
self.close()
return
elif isinstance(p, str) or isinstance(p, bytes):
+ if isinstance(p, str):
+ p = p.encode('ascii')
self.producer_fifo.pop()
- self.ac_out_buffer = self.ac_out_buffer + bytes(p)
+ self.ac_out_buffer = self.ac_out_buffer + p
return
data = p.more()
if data:
+ if isinstance(data, str):
+ data = data.encode('ascii')
self.ac_out_buffer = self.ac_out_buffer + bytes(data)
return
else:
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index e0dcc86..00c3ad4 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -405,8 +405,8 @@ class SMTPSimTests(TestCase):
self.assertEqual(smtp.vrfy(email), expected_known)
u = 'nobody@nowhere.com'
- expected_unknown = (550, bytes('No such user: %s'
- % smtplib.quoteaddr(u)))
+ expected_unknown = (550, ('No such user: %s'
+ % smtplib.quoteaddr(u)).encode('ascii'))
self.assertEqual(smtp.vrfy(u), expected_unknown)
smtp.quit()