The pip-specific Path implementation has been removed, and all its
usages replaced by pathlib.Path. The tmpdir and tmpdir_factory fixtures
are also removed, and all usages are replaced by tmp_path and
tmp_path_factory, which use pathlib.Path.
The pip() function now also accepts pathlib.Path so we don't need to put
str() everywhere. Path arguments are coerced with os.fspath() into str.
Since Python 3.6, subprocess supports decoding stdout and stderr. Like
before, decoding errors are handled using "backslashreplace".
One difference: In the event of a decoding error, pip previously logged
a warning before trying again with "backslashreplace". Subprocess does
not log such a warning.
With Python 2 dropped, only bytes need to be handled. Passing str was a
nop. These bytes/str boundaries are much clearer now.
There remains one use of str_to_display(): constole_to_str(). It
converts subprocess bytes output to str while handling decoding errors.
Use pyupgrade to convert simple string formatting to use f-string
syntax. pyupgrade is intentionally timid and will not create an f-string
if it would make the expression longer or if the substitution parameters
are anything but simple names or dotted names.
This updates `test_path_to_display` and `test_str_to_display__encoding`
to use the endian safe expected result instead of the hardcoded one.
This fixes https://github.com/pypa/pip/issues/7921
When reading bytes from subprocesses, use the locale encoding. Don't fail if the data is encoded incorrectly - instead, use the backslashreplace error handler (and warn the user).