msg15524 - (view) |
Author: Moshe Yudkowsky (myudkowsky) |
Date: 2003-04-20 15:36 |
Python 2.3a2+, Debian Summary: when I use the as_string() method on a multipart, multilevel message, I get an exception from email/quopriMIME.py, line 84, complaining about lstrip() of an integer. Initial condtions: I have a script that reads an email message, extracts some information, encapsulates the message and then forwards it with some commentary. This script works under Python 2.2.2. Failure: This script does not run under 2.3a2+ -- it fails on the as_string() method. In particular, at the file/lineno given above. Using the debugger, I see that in fact there *is* an integer at that point, the digit "1" to be exact. Looking up in the stack, I see that this function was called by the method _encode_chunks in Headers.py, and that the "newchunks" was [ (1, us-ascii ) ]. Please let me know if you need copies of the scripts, email messages, etc. |
|
|
msg15525 - (view) |
Author: Barry A. Warsaw (barry) *  |
Date: 2003-05-15 14:08 |
Logged In: YES user_id=12800 Yes, please upload (not paste) all relevant files needed for me to reproduce the problem. Please boil down your example as much as possible, but be sure to include a complete example. |
|
|
msg15526 - (view) |
Author: Barry A. Warsaw (barry) *  |
Date: 2003-05-19 20:00 |
Logged In: YES user_id=12800 Moving to Pending, waiting on more information. In 14 days, if there's no follow up this bug report will be automatically closed. |
|
|
msg15527 - (view) |
Author: Moshe Yudkowsky (myudkowsky) |
Date: 2003-05-26 04:14 |
Logged In: YES user_id=288768 Now, of course, I'm having trouble generating the exact same error. The enclosed script WFM under 2.2.2, but fails under 2.3b1+. The fault still seems to lie with "newchunks" but now the failure comes from Charset.py: Traceback (most recent call last): File "mailfail.py", line 203, in ? outMailString = wrapper.as_string() File "/usr/lib/python2.3/email/Message.py", line 113, in as_string g.flatten(self, unixfrom=unixfrom) File "/usr/lib/python2.3/email/Generator.py", line 102, in flatten self._write(msg) File "/usr/lib/python2.3/email/Generator.py", line 130, in _write self._dispatch(msg) File "/usr/lib/python2.3/email/Generator.py", line 156, in _dispatch meth(msg) File "/usr/lib/python2.3/email/Generator.py", line 230, in _handle_multipart g.flatten(part, unixfrom=False) File "/usr/lib/python2.3/email/Generator.py", line 102, in flatten self._write(msg) File "/usr/lib/python2.3/email/Generator.py", line 130, in _write self._dispatch(msg) File "/usr/lib/python2.3/email/Generator.py", line 156, in _dispatch meth(msg) File "/usr/lib/python2.3/email/Generator.py", line 297, in _handle_message g.flatten(msg.get_payload(0), unixfrom=False) File "/usr/lib/python2.3/email/Generator.py", line 102, in flatten self._write(msg) File "/usr/lib/python2.3/email/Generator.py", line 137, in _write self._write_headers(msg) File "/usr/lib/python2.3/email/Generator.py", line 183, in _write_headers header_name=h, continuation_ws='\t').encode() File "/usr/lib/python2.3/email/Header.py", line 412, in encode newchunks += self._split(s, charset, targetlen, splitchars) File "/usr/lib/python2.3/email/Header.py", line 297, in _split elen = charset.encoded_header_len(encoded) File "/usr/lib/python2.3/email/Charset.py", line 341, in encoded_header_len return len(s) I can either continue to try and recreate the original error, or if this is sufficient information to debug I'll stop now. |
|
|
msg15528 - (view) |
Author: Moshe Yudkowsky (myudkowsky) |
Date: 2003-05-26 14:26 |
Logged In: YES user_id=288768 I have deleted the original file, in which I'd accidentally left my email address, and replaced it with an anonymized version. |
|
|
msg15529 - (view) |
Author: Barry A. Warsaw (barry) *  |
Date: 2003-05-27 15:02 |
Logged In: YES user_id=12800 You're going to kick yourself. :) Look carefully at your code, where you assign values to the Content-Length and Lines headers in the inner spam message. You're setting those values to integers -- they have to be strings. If I wrap the values in str() it all works for me. |
|
|