[3.7] closes bpo-34056: Always return bytes from _HackedGetData.get_data(). (GH-8130) by miss-islington · Pull Request #8146 · python/cpython

@benjaminp @miss-islington

…pythonGH-8130)

* Always return bytes from _HackedGetData.get_data().

Ensure the imp.load_source shim always returns bytes by reopening the file in
binary mode if needed. Hash-based pycs have to receive the source code in bytes.

It's tempting to change imp.get_suffixes() to always return 'rb' as a mode, but
that breaks some stdlib tests and likely 3rdparty code, too.
(cherry picked from commit b0274f2)

Co-authored-by: Benjamin Peterson <benjamin@python.org>