on the most distros it points to py2 or it is not really deterministic.
The call itself is following:
fp.write('COMP_WORDBREAKS="$COMP_WORDBREAKS" python -m pytest 8>&1 9>&2')
I suppose it should use sys.executable or at least python3 as the py2 is not compatible anyway.