Merge lp:~wgrant/launchpad/emailauthentication.txt-2.6-fix into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Michael Nelson
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~wgrant/launchpad/emailauthentication.txt-2.6-fix
Merge into: lp:launchpad
Diff against target: 25 lines (+5/-4)
1 file modified
lib/canonical/launchpad/doc/emailauthentication.txt (+5/-4)
To merge this branch: bzr merge lp:~wgrant/launchpad/emailauthentication.txt-2.6-fix
Reviewer Review Type Date Requested Status
Michael Nelson (community) Approve
Review via email: mp+23449@code.launchpad.net

Commit message

Fix emailauthentication.txt to work with Python 2.6.

Description of the change

emailauthentication.txt currently fails like http://paste.ubuntu.com/414645/ when run under Python 2.6. http://bugs.python.org/issue1670765 partially fixed the tested issue -- not enough to remove the need for the hack, but enough to make the bug test fail.

Since that fix, msg.as_string() preserves folding correctly, but as_string() on the important part still does not. I've altered the test to check the relevant part, so the test now works on both 2.5 and 2.6. The doctest now also explains the reasonably opaque purpose of the tests.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Hi William,

Thanks for sorting this out. Just a suggestion below, see what you think.

> === modified file 'lib/canonical/launchpad/doc/emailauthentication.txt'
> --- lib/canonical/launchpad/doc/emailauthentication.txt 2009-02-19 23:55:18 +0000
> +++ lib/canonical/launchpad/doc/emailauthentication.txt 2010-04-15 01:53:20 +0000
> @@ -137,7 +137,10 @@
>
> Python's email library unfolds the headers, which means that we have to
> be careful when extracting the signed content when folded headers are
> -signed.
> +signed. This is done by manually parsing boundaries in
> +SignedMessage._getSignatureAndSignedContent. If the second test here
> +starts failing, Python is probably fixed, so the manual boundary parsing
> +hack can be removed.

Although that makes sense to me at the moment, if I look at that in 6months time when the second test fails, I'll struggle. I was wondering if instead we could say: If the second test here starts failing, [link to remaining python issue if it exists] has probably been fixed and it can be switched back to simply use as_string().

I'll wait to hear from you before sending this off to land.

>
> >>> msg = read_test_message('signed_folded_header.txt')
> >>> print msg.parsed_string #doctest: -NORMALIZE_WHITESPACE
> @@ -147,9 +150,7 @@
> boundary="--------------------EuxKj2iCbKjpUGkD"
> ...
>
> - >>> print msg.as_string() #doctest: -NORMALIZE_WHITESPACE
> - Date:...
> - ...
> + >>> print msg.get_payload(i=0).as_string() #doctest: -NORMALIZE_WHITESPACE
> Content-Type: multipart/mixed; boundary="--------------------EuxKj2iCbKjpUGkD"
> ...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/doc/emailauthentication.txt'
2--- lib/canonical/launchpad/doc/emailauthentication.txt 2009-02-19 23:55:18 +0000
3+++ lib/canonical/launchpad/doc/emailauthentication.txt 2010-04-15 01:53:20 +0000
4@@ -137,7 +137,10 @@
5
6 Python's email library unfolds the headers, which means that we have to
7 be careful when extracting the signed content when folded headers are
8-signed.
9+signed. This is done by manually parsing boundaries in
10+SignedMessage._getSignatureAndSignedContent. If the second test here
11+starts failing, Python is probably fixed, so the manual boundary parsing
12+hack can be removed.
13
14 >>> msg = read_test_message('signed_folded_header.txt')
15 >>> print msg.parsed_string #doctest: -NORMALIZE_WHITESPACE
16@@ -147,9 +150,7 @@
17 boundary="--------------------EuxKj2iCbKjpUGkD"
18 ...
19
20- >>> print msg.as_string() #doctest: -NORMALIZE_WHITESPACE
21- Date:...
22- ...
23+ >>> print msg.get_payload(i=0).as_string() #doctest: -NORMALIZE_WHITESPACE
24 Content-Type: multipart/mixed; boundary="--------------------EuxKj2iCbKjpUGkD"
25 ...
26