ui: convert to/from Optional[bytes] to Optional[str] in password manager
This password manager proxy is roughly the right-looking layer to
convert between strings and bytes. Many of these arguments can be
None, so we have a helper method to make the conversion preserve Nones
without exploding.
Differential Revision: https://phab.mercurial-scm.org/D886
tests: invoke run-tests.py in test-hghave using $PYTHON (
issue5697)
Some platforms (notably pkgsrc on NetBSD) only provide versioned
Python interpreters (eg `python2.7` exists, but `python` does not),
which exposes this error. We want to be running run-tests.py with the
python given in $PYTHON, since that might be `pypy` or `python3`.