Backports and enhancements for the contextlib module

WWW: https://contextlib2.readthedocs.org/
