Merge lp:~roadmr/checkbox/templates-utf8-encoding into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Merged at revision: 1446
Proposed branch: lp:~roadmr/checkbox/templates-utf8-encoding
Merge into: lp:checkbox
Diff against target: 45 lines (+5/-3)
3 files modified
checkbox/lib/template.py (+1/-1)
debian/changelog (+3/-1)
plugins/message_info.py (+1/-1)
To merge this branch: bzr merge lp:~roadmr/checkbox/templates-utf8-encoding
Reviewer Review Type Date Requested Status
Marc Tardif (community) Approve
Review via email: mp+111087@code.launchpad.net

Description of the change

This fixes the linked bug by explicitly setting the encoding when opening a job/template file.

It would in theory be better to honor the system's encoding, however note that the encoding set in /etc/default/locale is not necessarily the same as that of files that are shipped with a package. Also, since the encoding for the C locale, which is what upstart jobs have, is bogus, assuming UTF-8 in all cases seems safe enough.

Just for kicks, I tried seeing if the system had an invalid encoding set, to fall back to UTF-8 only in that case. But none of the things I tried (locale.getpreferredencoding, sys.getdefaultencoding and sys.getfilesystemencoding) let us discern between an incorrectly set (or unset) encoding and a valid but funky one; i.e. if the user *actually* has LANG=en_US.ANSI_X3.4-1968. So just assuming UTF-8 seems to offer the least chances of us shooting ourselves in the foot by trying to be too clever.

I tested this on a server (where the problem was first observed) by applying these changes manually and then rebooting the server, and there were no errors in the logfile; all jobs were loaded correctly.

To post a comment you must log in.
1440. By Daniel Manrique

Merged from trunk

1441. By Daniel Manrique

Fix crappy changelog formatting

Revision history for this message
Marc Tardif (cr3) wrote :

Looks perfectly reasonable, thanks for testing this extensively. Merging and building packages.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox/lib/template.py'
2--- checkbox/lib/template.py 2012-06-01 13:35:12 +0000
3+++ checkbox/lib/template.py 2012-06-19 19:41:20 +0000
4@@ -139,5 +139,5 @@
5 def load_filename(self, filename):
6 logging.info("Loading elements from filename: %s", filename)
7
8- file = open(filename, "r")
9+ file = open(filename, "r", encoding="utf-8")
10 return self.load_file(file, filename)
11
12=== modified file 'debian/changelog'
13--- debian/changelog 2012-06-19 18:28:47 +0000
14+++ debian/changelog 2012-06-19 19:41:20 +0000
15@@ -38,6 +38,8 @@
16 hunting through process lists.
17 * [FEATURE] Added script and jobs to collect and attach output from
18 alsa-info.sh.
19+ * Assume utf-8 encoding always, when opening template files.
20+ (LP: #1015174)
21
22 [Javier Collado]
23 * Submission screen in Qt interface updated to support certification client:
24@@ -126,7 +128,7 @@
25 * jobs/stress.txt.in: add OEM team's stress tests (including reboot and poweroff)
26 and log analysis jobs
27
28- -- Jeff Lane <jeff@ubuntu.com> Tue, 19 Jun 2012 14:02:37 -0400
29+ -- Daniel Manrique <roadmr@ubuntu.com> Tue, 19 Jun 2012 14:28:40 -0400
30
31 checkbox (0.13.8) precise; urgency=low
32
33
34=== modified file 'plugins/message_info.py'
35--- plugins/message_info.py 2012-06-01 21:38:37 +0000
36+++ plugins/message_info.py 2012-06-19 19:41:20 +0000
37@@ -125,7 +125,7 @@
38 self._manager.reactor.fire("report-messages", messages)
39
40 def message_filename(self, filename):
41- file = open(filename, "r")
42+ file = open(filename, "r", encoding="utf-8")
43 try:
44 self._manager.reactor.fire("message-file", file, filename)
45 finally:

Subscribers

People subscribed via source and target branches