[Distutils] pkginfo python 3 port

Sridhar Ratnakumar sridharr at activestate.com
Thu May 27 19:25:33 CEST 2010


On 2010-05-27, at 10:06 AM, Tres Seaver wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Sridhar Ratnakumar wrote:
>> For a start, how about this patch?
>> http://gist.github.com/415137
>> 
>> `email.parser` is available till 2.5; not sure about <=2.4 though.
> 
> Your patch does break with Python 2.4, which I would like to continue
> supporting.  Maybe we can add some more conditional imports and glue
> functions?  Something like the attached patch.

Sounds good.

> BTW, your patch	 also breaks a unit test, due to differences in behavior
> between the rfc822 parser and the email one:
> 
> ======================================================================
> FAIL: test_parse_Description
> (pkginfo.tests.test_distribution.DistributionTests)
> - ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File
> "/home/tseaver/projects/parcel/src/pkginfo/pkginfo/tests/test_distribution.py",
> line 104, in test_parse_Description
>    'This package enables integration with\n'
> AssertionError: 'This package enables integration with\n       foo
> servers.' != 'This package enables integration with\n foo servers.'


Hmm. RFC 822 (rfc822) and RFC 2822 have different "unfolding" rules for multiple line header. Curiously http://docs.python.org/library/rfc822.html is advertised as "Parse RFC 2822 mail headers," and yet it seems to unfold multiple lines in accordance with RFC 822.

I don't know what the solution to this problem is. I see that lines in the `Description` field (in PKG-INFO) are preceded with 8 spaces. So PKG-INFO is generated in accordance with RFC 822.

Is there a way to parse a RFC 822 message in Python 3?

-srid

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20100527/c4a9dd5e/attachment.html>


More information about the Distutils-SIG mailing list