[Python-bugs-list] [ python-Bugs-724621 ] email/quopriMIME.py exception on int (lstrip)

SourceForge.net noreply@sourceforge.net
Sun, 25 May 2003 21:14:45 -0700


Bugs item #724621, was opened at 2003-04-20 10:36
Message generated for change (Comment added) made by myudkowsky
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=724621&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Open
Resolution: None
Priority: 5
Submitted By: Moshe Yudkowsky (myudkowsky)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: email/quopriMIME.py exception on int (lstrip)

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Moshe Yudkowsky (myudkowsky)
Date: 2003-05-25 23:14

Message:
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.


----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-05-19 15:00

Message:
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.

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-05-15 09:08

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=724621&group_id=5470