From: Fred Drake Date: Sun, 20 May 2001 13:35:45 +0000 (+0000) Subject: Fix bug in smtplib example: the prompt said to end the message with ^D, X-Git-Tag: v2.1.1c1~127 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38665cabd056c9a0fa467a530046a599c33e10be;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Doc/lib/libsmtplib.tex b/Doc/lib/libsmtplib.tex index bc69387dd9f6..4a7b2dfdc89e 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