Upstream fixes for python2.6