def _push_cm_exit(self, cm, cm_exit):
        """Helper to correctly register callbacks to __exit__ methods"""
        def _exit_wrapper(*exc_details):
            return cm_exit(cm, *exc_details)
        _exit_wrapper.__self__ = cm
        self.push(_exit_wrapper)
Helper to correctly register callbacks to __exit__ methods
product/gradle-plugin/src/main/python/pip/_vendor/contextlib2.py