Add some Python 2.6 compatibility.
Try to work around the strange Python 3 behavior.