[New-bugs-announce] [issue8050] smtplib SMTP.sendmail (TypeError: expected string or buffer)

Allison Vollmann report at bugs.python.org
Wed Mar 3 16:00:17 CET 2010


New submission from Allison Vollmann <allisonvoll at gmail.com>:

When call SMTP.sendmail (with simple sendmail local sent and with smtp auth), the follow exception be raised (with debug output):

send: 'mail FROM:<xxx> size=5\r\n'
reply: '250 2.1.0 Ok\r\n'
reply: retcode (250); Msg: 2.1.0 Ok
send: 'rcpt TO:<xxx>\r\n'
reply: '250 2.1.5 Ok\r\n'
reply: retcode (250); Msg: 2.1.5 Ok
send: 'data\r\n'
reply: '354 End data with <CR><LF>.<CR><LF>\r\n'
reply: retcode (354); Msg: End data with <CR><LF>.<CR><LF>
data: (354, 'End data with <CR><LF>.<CR><LF>')

Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    s.sendmail(to, to, msg)
  File "C:\Python26\lib\smtplib.py", line 710, in sendmail
    (code,resp) = self.data(msg)
  File "C:\Python26\lib\smtplib.py", line 474, in data
    q = quotedata(msg)
  File "C:\Python26\lib\smtplib.py", line 157, in quotedata
    re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
  File "C:\Python26\lib\re.py", line 151, in sub
    return _compile(pattern, 0).sub(repl, string, count)
TypeError: expected string or buffer

This error appear because 'data' isn't an string object, just replacing "q = quotedata(msg)" for "q = quotedata(str(msg))" (in Python26\lib\smtplib.py:474) solves the problem, but i can't understand how this simple mistake does not be noticed

Teste in: 
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2,
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32

----------
components: Regular Expressions
messages: 100346
nosy: Allison.Vollmann
severity: normal
status: open
title: smtplib SMTP.sendmail (TypeError: expected string or buffer)
type: crash
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8050>
_______________________________________


More information about the New-bugs-announce mailing list