]> granicus.if.org Git - python/commit
closes bpo-34056: Always return bytes from _HackedGetData.get_data(). (GH-8130)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 7 Jul 2018 04:00:45 +0000 (21:00 -0700)
committerGitHub <noreply@github.com>
Sat, 7 Jul 2018 04:00:45 +0000 (21:00 -0700)
commit7bd6f0e5500f778e940374237b94651f60ae1990
treea3200c2fce1d51d88a51eb44bd09fc9522df83cf
parent127bd9bfd591c8ec1a97eb7f4037c8b884eef973
closes bpo-34056: Always return bytes from _HackedGetData.get_data(). (GH-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 b0274f2cddd36b49fe5080efbe160277ef546471)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
Lib/imp.py
Lib/test/test_imp.py
Misc/NEWS.d/next/Library/2018-07-05-22-45-46.bpo-34056.86isrU.rst [new file with mode: 0644]