summaryrefslogtreecommitdiffstats
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-11-21 22:09:45 (GMT)
committerGuido van Rossum <guido@python.org>2007-11-21 22:09:45 (GMT)
commit8a392d7387c9992537b0e1f66de989e34bd4eb4e (patch)
tree689dd92ee0ca56b2464982cb07b398af03f81f19 /Lib/smtplib.py
parentb08340053cb10af7290628ed624e4f7ec6be398b (diff)
downloadcpython-8a392d7387c9992537b0e1f66de989e34bd4eb4e.zip
cpython-8a392d7387c9992537b0e1f66de989e34bd4eb4e.tar.gz
cpython-8a392d7387c9992537b0e1f66de989e34bd4eb4e.tar.bz2
Convert the socket module to insist on bytes for input, and to return bytes
(not bytearray) on output. Discovered a bunch of places that were still depending on it accepting text strings.
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-xLib/smtplib.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index e10e327..0b4cbf0 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -295,12 +295,14 @@ class SMTP:
if self.debuglevel > 0: print("connect:", msg, file=stderr)
return (code, msg)
- def send(self, str):
- """Send `str' to the server."""
- if self.debuglevel > 0: print('send:', repr(str), file=stderr)
+ def send(self, s):
+ """Send `s' to the server."""
+ if self.debuglevel > 0: print('send:', repr(s), file=stderr)
if self.sock:
+ if isinstance(s, str):
+ s = s.encode("ascii")
try:
- self.sock.sendall(str)
+ self.sock.sendall(s)
except socket.error:
self.close()
raise SMTPServerDisconnected('Server not connected')