New submission from Axel Rau <axel....@chaos1.de>:

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

----------
components: Library (Lib)
messages: 133590
nosy: axel
priority: normal
severity: normal
status: open
title: smtplib._quote_periods triggers spurious type error in re.sub
type: behavior
versions: Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11837>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to