I don't quite see how this should be a problem...

So when dealing with text, an application should (ideally) go through 3 steps:

* ingest binary data from the outside, and decode it (cross fingers it knows the right encoding) into unicode
* Work with the data, as text, in the language's internal unicode representation
* Finally encode the data when outputting it back into the world

`read_text_file(filename)` is trying, to the best of its ability, to perform the first step here. Takes binary data from disk and transform it into unicode for the rest of `pip` to do things with. If you find yourself writing `data = data.decode(enc).encode(enc)` then something is going horribly wrong.

So I'd guess is either there is some data involved with the problem function calls not being converted to unicode upon ingestion (so everything internally is unicode), or we're not encoding back when doing output properly. The error suggests we're trying to treat unicode text as binary, so we're missing a needed encode step somewhere.