This patch resolves most of the test failures introduced by Jeffrey Yasskin's immutable bytes change. The remaining failures are: test_io test_mailbox test_mhlib test_old_mailbox test_email test_univnewlines The first 4 are the same problem. An array('B') is passed to PyArg_ParseTuple("t#..."). This results in "TypeError: Cannot be a character buffer" from ascii_decode in _codecsmodule.c. Note: This patch is also includes Jeffrey's original changes.
The attached patch (mostly based on hupp's test fixes) passes all of the tests on my machine. The issue with ParseTuple is described in http://bugs.python.org/issue1200. I intend to clean the patch up some, but this is enough to see what the issues tend to be.