core: Fix issue with Python 2.6 (cStringIO is buggy).