python-utils-r1.eclass: Fix python_optimize to take all of sys.path
authorMichał Górny <mgorny@gentoo.org>
Wed, 23 Oct 2019 10:08:27 +0000 (12:08 +0200)
committerMichał Górny <mgorny@gentoo.org>
Fri, 1 Nov 2019 13:15:58 +0000 (14:15 +0100)
Make sure to append NUL to every path in sys.path, rather than using
it as a separator between output entries.  This fixes a bug when
the last path entry was silently discarded, and the function stopped
working with PyPy as a result.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
eclass/python-utils-r1.eclass

index f8f51ecb694a6769bebaf3a0c08db0e13829807e..549dd5f2e56e02a32ab27151188ddc6e64bb5c4a 100644 (file)
@@ -692,7 +692,7 @@ python_optimize() {
                        if [[ ${f} == /* && -d ${D%/}${f} ]]; then
                                set -- "${D%/}${f}" "${@}"
                        fi
-               done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die)
+               done < <("${PYTHON}" -c 'import sys; print("".join(x + "\0" for x in sys.path))' || die)
 
                debug-print "${FUNCNAME}: using sys.path: ${*/%/;}"
        fi