mirror of
https://github.com/python/cpython
synced 2024-09-04 15:56:13 +00:00
Fix test_smtplib by munging asynchat some more.
This commit is contained in:
parent
828f04ac3f
commit
74e68c751f
|
@ -46,6 +46,7 @@
|
|||
you - by calling your self.found_terminator() method.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import socket
|
||||
import asyncore
|
||||
from collections import deque
|
||||
|
@ -91,6 +92,8 @@ def handle_read (self):
|
|||
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 @@ def handle_read (self):
|
|||
# 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 @@ def refill_buffer (self):
|
|||
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:
|
||||
|
|
|
@ -405,8 +405,8 @@ def testVRFY(self):
|
|||
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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue