Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9719fe

Browse files
committed
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.
1 parent 09daff4 commit e9719fe

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Doc/lib/libsmtplib.tex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,20 @@ \subsection{SMTP Example \label{SMTP-example}}
241241
import string
242242
243243
def prompt(prompt):
244-
return string.strip(raw_input(prompt))
244+
return raw_input(prompt).strip()
245245
246246
fromaddr = prompt("From: ")
247-
toaddrs = string.split(prompt("To: "))
247+
toaddrs = prompt("To: ").split()
248248
print "Enter message, end with ^D:"
249249
250250
# Add the From: and To: headers at the start!
251251
msg = ("From: %s\r\nTo: %s\r\n\r\n"
252252
% (fromaddr, string.join(toaddrs, ", ")))
253253
while 1:
254-
line = raw_input()
254+
try:
255+
line = raw_input()
256+
except EOFError:
257+
break
255258
if not line:
256259
break
257260
msg = msg + line

0 commit comments

Comments
 (0)