This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author axel
Recipients axel
Date 2011-04-12.17:09:18
SpamBayes Score 0.00031355218
Marked as misclassified No
Message-id <1302628161.84.0.82021620589.issue11837@psf.upfronthosting.co.za>
In-reply-to
Content
While debugging this
  http://article.gmane.org/gmane.comp.python.general/687767
email problem, I'm getting:
---
 File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/smtplib.py", line 794, in send_message
    rcpt_options)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/smtplib.py", line 762, in sendmail
    (code, resp) = self.data(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/smtplib.py", line 518, in data
    q = _quote_periods(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/smtplib.py", line 166, in _quote_periods
    return re.sub(br'(?m)^\.', '..', bindata)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/re.py", line 168, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: sequence item 1: expected bytes, str found
---
The following instrumentation:
---
def sub(pattern, repl, string, count=0, flags=0):
    print('re.sub: pattern=%s, repl=%s, string=%s' % (pattern.__class__.__name__, repl.__class__.__name__, string.__class__.__name__))
    return _compile(pattern, flags).sub(repl, string, count)
---
shows (in my test case with 2nd mail):
---
re.sub: pattern=bytes, repl=str, string=bytes
---
Changing smtplib._quote_periods(bindata) from
---
def _quote_periods(bindata):
    return re.sub(br'(?m)^\.', '..', bindata)
---
to:
---
def _quote_periods(bindata):
    return re.sub(br'(?m)^\.', b'..', bindata)
---
Fixes the problem for me.

Platform is Mac OS X 10.6.7, 64-bit.
Problem happens always on 2nd mail being sent.
Problem still exists with python 3.2.1a
History
Date User Action Args
2011-04-12 17:09:21axelsetrecipients: + axel
2011-04-12 17:09:21axelsetmessageid: <1302628161.84.0.82021620589.issue11837@psf.upfronthosting.co.za>
2011-04-12 17:09:18axellinkissue11837 messages
2011-04-12 17:09:18axelcreate