fixes for py26 and py3k compatibility