Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o, Alexander Berntsen <bernalex@g.o>, "michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] Warn if LC_CTYPE does not toupper()/tolower() ASCII chars correctly
Date: Fri, 13 Nov 2015 19:58:13
Message-Id: 564640CB.9070103@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] Warn if LC_CTYPE does not toupper()/tolower() ASCII chars correctly by "Michał Górny"
1 On 11/13/2015 11:41 AM, Michał Górny wrote:
2 > On Fri, 13 Nov 2015 12:46:31 +0100
3 > Alexander Berntsen <bernalex@g.o> wrote:
4 >
5 >> -----BEGIN PGP SIGNED MESSAGE-----
6 >> Hash: SHA512
7 >>
8 >> On 11/11/15 22:33, Michał Górny wrote:
9 >>> Output a warning if LC_CTYPE is set to a value that causes libc
10 >>> toupper() and/or tolower() conversions not apply correctly to printable
11 >>> ASCII characters.
12 >> I think you a verb.
13 >>
14 >>> + "Please consider enabling another locale (such as " +
15 >>> + "en_US.UTF-8) in /etc/locale.gen and setting it " +
16 >>> + "as LC_TYPE in make.conf.")
17 >> Not sure this is really necessary.
18 >>
19 >>> + if uc != ruc:
20 >>> + msg.extend([
21 >>> + " %s -> %s" % (''.join([chr(x) for x in lc]),
22 >>> + ''.join([chr(x) for x in ruc])),
23 >>> + " %28s: %s" % ('expected',
24 >>> + ''.join([chr(x) for x in uc]))])
25 >>> + if lc != rlc:
26 >>> + msg.extend([
27 >>> + " %s -> %s" % (''.join([chr(x) for x in uc]),
28 >>> + ''.join([chr(x) for x in rlc])),
29 >>> + " %28s: %s" % ('expected',
30 >>> + ''.join([chr(x) for x in lc]))])
31 >> This is very silly. Even a for loop or list comprehension would be
32 >> better.
33 >
34 > Then please suggest a better one since I don't really understand what
35 > you dislike, nor what you want.
36 >
37 > That said, I don't really like this patch. If you can come up with
38 > something better, then please by all means do.
39 >
40
41 It's the redundancy of the code. Here's an example with less redundancy:
42
43 charify = lambda sequence: ''.join(chr(x) for x in sequence)
44
45 msg.extend([
46 " %s -> %s" % (charify(lc), charify(uc)),
47 " %28s: %s" % ('expected', charify(uc))])
48
49 --
50 Thanks,
51 Zac