Some additional (temporary) info about the patch: The last test failures can be seen here: http://hgbuildbot.kublai.com/builders/Windows 2008 R2 hg tests (stable)/builds/32/steps/run-tests.py (python2.6)/logs/stdio Not sure if rstrip('\n') really solves the problem. If not, maybe only \n could be encoded?