[Python-bugs-list] [ python-Feature Requests-494034 ] a smarter rfc822.dump_address_pair()

noreply@sourceforge.net noreply@sourceforge.net
Mon, 18 Mar 2002 10:01:28 -0800


Feature Requests item #494034, was opened at 2001-12-16 20:24
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=494034&group_id=5470

Category: Python Library
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Jason R. Mastaler (jasonrm)
Assigned to: Barry Warsaw (bwarsaw)
Summary: a smarter rfc822.dump_address_pair()

Initial Comment:
Please see:
http://mail.python.org/pipermail/python-list/2001-December/075881.html

I'm turning this into a feature request since
I didn't get any responses on comp.lang.python.


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

>Comment By: Barry Warsaw (bwarsaw)
Date: 2002-03-18 13:01

Message:
Logged In: YES 
user_id=12800

Excellent!  I'm commiting this to standalone email pkg first
(for v1.3) and will merge it into the Python distro for
python 2.3.

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

Comment By: Jason R. Mastaler (jasonrm)
Date: 2002-03-18 13:00

Message:
Logged In: YES 
user_id=85984

Looks good to me.



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

Comment By: Barry Warsaw (bwarsaw)
Date: 2002-03-18 11:33

Message:
Logged In: YES 
user_id=12800

Here's a simplification, based on re.  I added a bunch of
test cases that failed under stock email 1.2, passed with
your patch, and still pass with mine.  Let me know what you
think.  If you like it, I'll commit this to the email
package and fold it into the Python distro.

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

Comment By: Jason R. Mastaler (jasonrm)
Date: 2002-03-12 17:52

Message:
Logged In: YES 
user_id=85984

Take a look at the attached formataddr()
implementation.

Unlike dump_address_pair(), it takes care
to both double-quote the fullname only
when necessary, and also escape any
delimiting lexical tokens with a backslash.
This will hopefully produce a more RFC 2822 
compliant result.



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

Comment By: Jason R. Mastaler (jasonrm)
Date: 2002-03-07 13:07

Message:
Logged In: YES 
user_id=85984

Yes, I think formataddr() is a much better
name.  dump_address_pair() is not very intuitive
at all IMO.




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

Comment By: Barry Warsaw (bwarsaw)
Date: 2002-03-07 12:49

Message:
Logged In: YES 
user_id=12800

Oh, and how motivated would you be to writing a new
implementation of parseaddr()? <wink>.

There are two problems with the one from rfc822.py.  First,
we've got the ugly workaround for a bug in older versions
(where realname='' and emailaddr=None).  Second, it has a
nasty bug when the email address contains embedded spaces:
it collapses the spaces:

>>> from email.Utils import parseaddr
>>> parseaddr('foo bar@wooz.org')
('', 'foobar@wooz.org')
>>> parseaddr('<foo bar@wooz.org>')
('', 'foobar@wooz.org')

Boo, hiss.  Of course parseaddr() would be more involved to
implement in an RFC 2822 compliant way, but it would be very
cool.

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

Comment By: Barry Warsaw (bwarsaw)
Date: 2002-03-07 12:45

Message:
Logged In: YES 
user_id=12800

I'd like to gradually reduce the dependence on rfc822.py so
please write the new implementation for email.Utils.  This
is exactly the route taken for formatdate().

Also, let's come up with a better name than
dump_address_pairs().  We have a parsedate() and a
formatdate().  We've got a parseaddr() so what do you think
about formataddr()?  We can keep dump_address_pairs as a
back-compat alias.

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

Comment By: Jason R. Mastaler (jasonrm)
Date: 2002-03-07 12:40

Message:
Logged In: YES 
user_id=85984

I'd like to take a shot at coding a better
dump_address_pair method.  Before I start, should
the diff be against rfc822 or email.Utils? (which
currently just imports dump_address_pair from
rfc822).  Perhaps a new implementation like this
should just go into email, and
rfc822.dump_address_pair() can just be left as is,
similar to how the formatdate method was
reimplemented for email.

Let me know what you think.



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

Comment By: Barry Warsaw (bwarsaw)
Date: 2001-12-17 17:41

Message:
Logged In: YES 
user_id=12800

If you get to it before I do, upload it here... :)

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

Comment By: Jason R. Mastaler (jasonrm)
Date: 2001-12-17 17:28

Message:
Logged In: YES 
user_id=85984

Thanks Barry.  If you don't think you'll have time to
write the code for this, I can try and work on a patch.


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

Comment By: Barry Warsaw (bwarsaw)
Date: 2001-12-17 10:04

Message:
Logged In: YES 
user_id=12800

Claiming this item.  There appears to be no groups set for
the feature request tracker, but I'll look at this for
Python 2.3 (to late to add it to Python 2.2).

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

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=494034&group_id=5470