diff options
author | Fred Drake <fdrake@acm.org> | 2001-05-20 12:26:04 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-05-20 12:26:04 (GMT) |
commit | e9719fe1a79d1bf0db1729940e84538ea83dff88 (patch) | |
tree | 18d707b1f4196d486f21c998b79bc11932f27570 /Doc | |
parent | 09daff4596048f640cd7583066f3ff60986d800c (diff) | |
download | cpython-e9719fe1a79d1bf0db1729940e84538ea83dff88.zip cpython-e9719fe1a79d1bf0db1729940e84538ea83dff88.tar.gz cpython-e9719fe1a79d1bf0db1729940e84538ea83dff88.tar.bz2 |
Fix bug in smtplib example: the prompt said to end the message with ^D,
but doing so raised EOFError. This makes it work as advertised and
converts to string methods where reasonable.
This closes SF bug #424776.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libsmtplib.tex | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/lib/libsmtplib.tex b/Doc/lib/libsmtplib.tex index bc69387d..4a7b2df 100644 --- a/Doc/lib/libsmtplib.tex +++ b/Doc/lib/libsmtplib.tex @@ -241,17 +241,20 @@ import smtplib import string def prompt(prompt): - return string.strip(raw_input(prompt)) + return raw_input(prompt).strip() fromaddr = prompt("From: ") -toaddrs = string.split(prompt("To: ")) +toaddrs = prompt("To: ").split() print "Enter message, end with ^D:" # Add the From: and To: headers at the start! msg = ("From: %s\r\nTo: %s\r\n\r\n" % (fromaddr, string.join(toaddrs, ", "))) while 1: - line = raw_input() + try: + line = raw_input() + except EOFError: + break if not line: break msg = msg + line |