Merge lp:~laney/ubuntu-archive-tools/cm-utf8 into lp:ubuntu-archive-tools

Proposed by Iain Lane
Status: Merged
Merged at revision: 1225
Proposed branch: lp:~laney/ubuntu-archive-tools/cm-utf8
Merge into: lp:ubuntu-archive-tools
Diff against target: 27 lines (+17/-0)
1 file modified
component-mismatches (+17/-0)
To merge this branch: bzr merge lp:~laney/ubuntu-archive-tools/cm-utf8
Reviewer Review Type Date Requested Status
Andy Whitcroft Approve
Review via email: mp+370117@code.launchpad.net

Description of the change

Fix component-mismatches crashing due to the usual python unicode weirdness

To post a comment you must log in.
Revision history for this message
Andy Whitcroft (apw) wrote :

Can I just say yeuch. But it looks to do what is claimed.

review: Approve
1225. By Andy Whitcroft

Merge: lp:~laney/ubuntu-archive-tools/cm-utf8

Fixes component-missmatches in the face of utf-8 user 'names' in launchpad.

Signed-off-by: Andy Whitcroft <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'component-mismatches'
2--- component-mismatches 2018-03-09 04:11:21 +0000
3+++ component-mismatches 2019-07-15 10:05:25 +0000
4@@ -889,6 +889,23 @@
5 else:
6 options.html_output = None
7
8+ if sys.version >= '3':
9+ # Force encoding to UTF-8 even in non-UTF-8 locales.
10+ import io
11+ sys.stdout = io.TextIOWrapper(
12+ sys.stdout.detach(), encoding="UTF-8", line_buffering=True)
13+ else:
14+ # Avoid having to do .encode('UTF-8') everywhere. This is a pain; I wish
15+ # Python supported something like "sys.stdout.encoding = 'UTF-8'".
16+ def fix_stdout():
17+ import codecs
18+ sys.stdout = codecs.EncodedFile(sys.stdout, 'UTF-8')
19+ def null_decode(input, errors='strict'):
20+ return input, len(input)
21+ sys.stdout.decode = null_decode
22+
23+ fix_stdout()
24+
25 options.time = time.time()
26 options.timestamp = time.strftime(
27 '%a %b %e %H:%M:%S %Z %Y', time.gmtime(options.time))

Subscribers

People subscribed via source and target branches