Merge lp:~bac/launchpad/bug-567985 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Jonathan Lange
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~bac/launchpad/bug-567985
Merge into: lp:launchpad
Diff against target: 25 lines (+4/-4)
1 file modified
lib/devscripts/ec2test/ec2test-remote.py (+4/-4)
To merge this branch: bzr merge lp:~bac/launchpad/bug-567985
Reviewer Review Type Date Requested Status
Jonathan Lange (community) Approve
Review via email: mp+23868@code.launchpad.net

Commit message

Unbreak ec2test-remote send_mail

Description of the change

= Summary =

Programming error breaks ec2test.

== Proposed fix ==

The variable that holds the data read from a file is used to try to
close the file. Don't do that.

== Pre-implementation notes ==

N/A

== Implementation details ==

As above.

== Tests ==

None, sadly.

== Demo and Q/A ==

Run it through ec2. The actual snippet was tested locally.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/devscripts/ec2test/ec2test-remote.py

== Pyflakes notices ==

lib/devscripts/ec2test/ec2test-remote.py
    35: from __future__ imports must occur at the beginning of the file
    from __future__ import with_statement

== Pylint notices ==

lib/devscripts/ec2test/ec2test-remote.py
    35: [W0410] __future__ import is not the first non docstring statement
    498: [C0321] More than one statement on a single line

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

Oh man. I'm so sorry I let this happen.

Goes to show that even making minor changes without testing is doomed to failure.

Thanks for the fix!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/devscripts/ec2test/ec2test-remote.py'
2--- lib/devscripts/ec2test/ec2test-remote.py 2010-04-21 11:16:21 +0000
3+++ lib/devscripts/ec2test/ec2test-remote.py 2010-04-21 17:55:32 +0000
4@@ -32,6 +32,8 @@
5
6 import subunit
7
8+from __future__ import with_statement
9+
10
11 class SummaryResult(unittest.TestResult):
12 """Test result object used to generate the summary."""
13@@ -225,10 +227,8 @@
14 message['Subject'] = subject
15
16 # Make the body.
17- try:
18- summary = open(summary_filename, 'r').read()
19- finally:
20- summary.close()
21+ with open(summary_filename, 'r') as summary_fd:
22+ summary = summary_fd.read()
23 body = MIMEText.MIMEText(summary, 'plain', 'utf8')
24 body['Content-Disposition'] = 'inline'
25 message.attach(body)