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
=== modified file 'component-mismatches'
--- component-mismatches 2018-03-09 04:11:21 +0000
+++ component-mismatches 2019-07-15 10:05:25 +0000
@@ -889,6 +889,23 @@
889 else:889 else:
890 options.html_output = None890 options.html_output = None
891891
892 if sys.version >= '3':
893 # Force encoding to UTF-8 even in non-UTF-8 locales.
894 import io
895 sys.stdout = io.TextIOWrapper(
896 sys.stdout.detach(), encoding="UTF-8", line_buffering=True)
897 else:
898 # Avoid having to do .encode('UTF-8') everywhere. This is a pain; I wish
899 # Python supported something like "sys.stdout.encoding = 'UTF-8'".
900 def fix_stdout():
901 import codecs
902 sys.stdout = codecs.EncodedFile(sys.stdout, 'UTF-8')
903 def null_decode(input, errors='strict'):
904 return input, len(input)
905 sys.stdout.decode = null_decode
906
907 fix_stdout()
908
892 options.time = time.time()909 options.time = time.time()
893 options.timestamp = time.strftime(910 options.timestamp = time.strftime(
894 '%a %b %e %H:%M:%S %Z %Y', time.gmtime(options.time))911 '%a %b %e %H:%M:%S %Z %Y', time.gmtime(options.time))

Subscribers

People subscribed via source and target branches