1 |
On 10/31/2015 10:23 PM, Mike Frysinger wrote: |
2 |
> The current code implements a lot of ad-hoc argument parsing when it |
3 |
> could simply let the argparse module do it all for it. This makes the |
4 |
> code easier to understand and extend in the process. |
5 |
> --- |
6 |
> bin/xpak-helper.py | 68 ++++++++++++++++++++---------------------------------- |
7 |
> 1 file changed, 25 insertions(+), 43 deletions(-) |
8 |
> |
9 |
> diff --git a/bin/xpak-helper.py b/bin/xpak-helper.py |
10 |
> index 8c965ec..1b2883d 100755 |
11 |
> --- a/bin/xpak-helper.py |
12 |
> +++ b/bin/xpak-helper.py |
13 |
[snip] |
14 |
> -def main(argv): |
15 |
> |
16 |
> - if argv and isinstance(argv[0], bytes): |
17 |
> - for i, x in enumerate(argv): |
18 |
> - argv[i] = portage._unicode_decode(x, errors='strict') |
19 |
|
20 |
You've dropped the _unicode_decode call. |
21 |
|
22 |
In order to handle python3 with arguments containing UTF-8 characters |
23 |
(in ${PKGDIR}) and a mis-matched sys.getfilesystemencoding() value, it's |
24 |
safest to decode the arguments like chmod-lite.py does. We should create |
25 |
a function for this code which is also duplicated in install.py: |
26 |
|
27 |
if sys.hexversion >= 0x3000000: |
28 |
# We can't trust that the filesystem encoding (locale dependent) |
29 |
# correctly matches the arguments, so use surrogateescape to |
30 |
# pass through the original argv bytes for Python 3. |
31 |
fs_encoding = sys.getfilesystemencoding() |
32 |
files = [x.encode(fs_encoding, 'surrogateescape') for x in files] |
33 |
-- |
34 |
Thanks, |
35 |
Zac |