backport to python2.7