◐ Shell
reader mode source ↗
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
52 changes: 52 additions & 0 deletions Lib/imaplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
__version__ = "2.58"

import binascii, errno, random, re, socket, subprocess, sys, time, calendar
from datetime import datetime, timezone, timedelta
from io import DEFAULT_BUFFER_SIZE

try:
import ssl
Expand Down Expand Up @@ -131,6 +133,10 @@
_Untagged_status = br'\* (?P<data>\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?'



class IMAP4:

Expand Up @@ -194,6 +200,7 @@ def __init__(self, host='', port=IMAP4_PORT, timeout=None):
self.continuation_response = '' # Last continuation response
self.is_readonly = False # READ-ONLY desired state
self.tagnum = 0
self._tls_established = False
self._mode_ascii()

Expand Down Expand Up @@ -611,6 +618,9 @@ def login(self, user, password):
if typ != 'OK':
raise self.error(dat[-1])
self.state = 'AUTH'
return typ, dat


Expand Down Expand Up @@ -655,6 +665,44 @@ def lsub(self, directory='""', pattern='*'):
typ, dat = self._simple_command(name, directory, pattern)
return self._untagged_response(typ, dat, name)

def myrights(self, mailbox):
"""Show my ACLs for a mailbox (i.e. the rights that I have on mailbox).

Expand Down Expand Up @@ -1058,11 +1106,15 @@ def _command_complete(self, name, tag):

def _get_capabilities(self):
typ, dat = self.capability()
if dat == [None]:
raise self.error('no CAPABILITY response from server')
dat = str(dat[-1], self._encoding)
dat = dat.upper()
self.capabilities = tuple(dat.split())


def _get_response(self):
Expand Down
53 changes: 53 additions & 0 deletions Lib/test/test_imaplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,59 @@ def test_unselect(self):
self.assertEqual(data[0], b'Returned to authenticated state. (Success)')
self.assertEqual(client.state, 'AUTH')


class NewIMAPTests(NewIMAPTestsMixin, unittest.TestCase):
imap_class = imaplib.IMAP4
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Toggle all file notes Toggle all file annotations