librelist archives

« back to archive

minor bug?

minor bug?

From:
paul wisehart
Date:
2009-08-29 @ 15:32
Hi,

Is the following a bug?:

If you send email from the command line with just ints
in the body you get an error.

lamson send -sender me@mydomain.com -to test@test.com
-subject test@test.com  \
-subject "asd asd" \
-body "12312312312312" \
-port 8823

<tracebacks snipped>
....
198, in extract_payload
     self.add_text(mail.body)
   File "/usr/lib64/python2.6/site-packages/lamson/encoding.py", line
180, in add_text
     encoded = content.encode('ascii')
AttributeError: 'int' object has no attribute 'encode'


The same commandline, with some letters added to the body works.

Lemme know if you need me to elaborate.

thanks,

--
paul

Re: minor bug?

From:
Zed A. Shaw
Date:
2009-08-29 @ 15:51
On Sat, Aug 29, 2009 at 11:32:01AM -0400, paul wisehart wrote:
> Hi,
> 
> Is the following a bug?:
> 
> If you send email from the command line with just ints
> in the body you get an error.

Nope, that's just how shells screw things up.  What's going on is when
you put "123456789" in the shell, it translates into an argument in
sys.argv of 123456789 because the shell peels off the "".  It's not
Python, so the "" kind of has no meaning as an argument.  Lamson's
argument parser then (correctly) interprets this as an integer and then
that blows up inside since an integer doesn't make sense as a email
body.

For now, just don't do that.  I'll go throw a str() around the body
argument so it's always a string for the next release.

-- 
Zed A. Shaw
http://zedshaw.com/

Re: minor bug?

From:
paul wisehart
Date:
2009-08-29 @ 16:02
Zed A. Shaw wrote:
> Nope, that's just how shells screw things up.  What's going on is when
> you put "123456789" in the shell, it translates into an argument in
> sys.argv of 123456789 because the shell peels off the "". 

Thanks, that makes sense.