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