mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
09daff4596
commit
e9719fe1a7
1 changed files with 6 additions and 3 deletions
|
@ -241,17 +241,20 @@ import smtplib
|
||||||
import string
|
import string
|
||||||
|
|
||||||
def prompt(prompt):
|
def prompt(prompt):
|
||||||
return string.strip(raw_input(prompt))
|
return raw_input(prompt).strip()
|
||||||
|
|
||||||
fromaddr = prompt("From: ")
|
fromaddr = prompt("From: ")
|
||||||
toaddrs = string.split(prompt("To: "))
|
toaddrs = prompt("To: ").split()
|
||||||
print "Enter message, end with ^D:"
|
print "Enter message, end with ^D:"
|
||||||
|
|
||||||
# Add the From: and To: headers at the start!
|
# Add the From: and To: headers at the start!
|
||||||
msg = ("From: %s\r\nTo: %s\r\n\r\n"
|
msg = ("From: %s\r\nTo: %s\r\n\r\n"
|
||||||
% (fromaddr, string.join(toaddrs, ", ")))
|
% (fromaddr, string.join(toaddrs, ", ")))
|
||||||
while 1:
|
while 1:
|
||||||
|
try:
|
||||||
line = raw_input()
|
line = raw_input()
|
||||||
|
except EOFError:
|
||||||
|
break
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
msg = msg + line
|
msg = msg + line
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue