(self, exc_type, exc_val, exc_tb)
| 1484 | return self |
| 1485 | |
| 1486 | def __exit__(self, exc_type, exc_val, exc_tb): |
| 1487 | imap = self._imap |
| 1488 | |
| 1489 | if __debug__ and imap.debug >= 4: |
| 1490 | imap._mesg('idle done') |
| 1491 | imap.state = self._saved_state |
| 1492 | |
| 1493 | # Stop intercepting untagged responses before sending DONE, |
| 1494 | # since we can no longer deliver them via iteration. |
| 1495 | imap._idle_capture = False |
| 1496 | |
| 1497 | # If we captured untagged responses while the IDLE command |
| 1498 | # continuation request was still pending, but the user did not |
| 1499 | # iterate over them before exiting IDLE, we must put them |
| 1500 | # someplace where the user can retrieve them. The only |
| 1501 | # sensible place for this is the untagged_responses dict, |
| 1502 | # despite its unfortunate inability to preserve the relative |
| 1503 | # order of different response types. |
| 1504 | if leftovers := len(imap._idle_responses): |
| 1505 | if __debug__ and imap.debug >= 4: |
| 1506 | imap._mesg(f'idle quit with {leftovers} leftover responses') |
| 1507 | while imap._idle_responses: |
| 1508 | typ, data = imap._idle_responses.pop(0) |
| 1509 | # Append one fragment at a time, just as _get_response() does |
| 1510 | for datum in data: |
| 1511 | imap._append_untagged(typ, datum) |
| 1512 | |
| 1513 | try: |
| 1514 | imap.send(b'DONE' + CRLF) |
| 1515 | status, [msg] = imap._command_complete('IDLE', self._tag) |
| 1516 | if __debug__ and imap.debug >= 4: |
| 1517 | imap._mesg(f'idle status: {status} {msg!r}') |
| 1518 | except OSError: |
| 1519 | if not exc_type: |
| 1520 | raise |
| 1521 | |
| 1522 | return False # Do not suppress context body exceptions |
| 1523 | |
| 1524 | def __iter__(self): |
| 1525 | return self |
nothing calls this directly
no test coverage detected