Backports and enhancements for the contextlib module
