diff -r 1940b72b0a02 Lib/test/test_bz2.py --- a/Lib/test/test_bz2.py Tue Nov 08 20:34:22 2016 +0200 +++ b/Lib/test/test_bz2.py Fri Nov 11 10:00:15 2016 +0100 @@ -84,13 +84,17 @@ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - pop.stdin.write(data) - pop.stdin.close() - ret = pop.stdout.read() + try: + pop.stdin.write(data) + pop.stdin.close() + except BrokenPipeError: + ret = None + else: + ret = pop.stdout.read() pop.stdout.close() if pop.wait() != 0: - ret = bz2.decompress(data) - return ret + ret = None + return ret if ret is not None else bz2.decompress(data) class BZ2FileTest(BaseTest):