Undo the patch.
(self, *exc_info)
| 1569 | raise |
| 1570 | |
| 1571 | def __exit__(self, *exc_info): |
| 1572 | """Undo the patch.""" |
| 1573 | if self.is_local and self.temp_original is not DEFAULT: |
| 1574 | setattr(self.target, self.attribute, self.temp_original) |
| 1575 | else: |
| 1576 | delattr(self.target, self.attribute) |
| 1577 | if not self.create and (not hasattr(self.target, self.attribute) or |
| 1578 | self.attribute in ('__doc__', '__module__', |
| 1579 | '__defaults__', '__annotations__', |
| 1580 | '__kwdefaults__')): |
| 1581 | # needed for proxy objects like django settings |
| 1582 | setattr(self.target, self.attribute, self.temp_original) |
| 1583 | |
| 1584 | del self.temp_original |
| 1585 | del self.is_local |
| 1586 | del self.target |
| 1587 | exit_stack = self._exit_stack |
| 1588 | del self._exit_stack |
| 1589 | return exit_stack.__exit__(*exc_info) |
| 1590 | |
| 1591 | |
| 1592 | def start(self): |