Backport to Python 2