summaryrefslogtreecommitdiffstats
path: root/Lib/imaplib.py
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-04-27 14:52:55 (GMT)
committerGitHub <noreply@github.com>2020-04-27 14:52:55 (GMT)
commitc5c42815ecb560bbf34db99b0e15fe9b604be889 (patch)
tree819b18345d9d082af9ed6db4e51e9ab566a31538 /Lib/imaplib.py
parent91a5ae18351027867e99c96db5ea235d9c42e47a (diff)
downloadcpython-c5c42815ecb560bbf34db99b0e15fe9b604be889.zip
cpython-c5c42815ecb560bbf34db99b0e15fe9b604be889.tar.gz
cpython-c5c42815ecb560bbf34db99b0e15fe9b604be889.tar.bz2
bpo-40375: Implement imaplib.IMAP4.unselect (GH-19712)
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r--Lib/imaplib.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index abfdd73..d9720f2 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -98,6 +98,7 @@ Commands = {
'THREAD': ('SELECTED',),
'UID': ('SELECTED',),
'UNSUBSCRIBE': ('AUTH', 'SELECTED'),
+ 'UNSELECT': ('SELECTED',),
}
# Patterns to match server responses
@@ -902,6 +903,22 @@ class IMAP4:
return self._simple_command('UNSUBSCRIBE', mailbox)
+ def unselect(self):
+ """Free server's resources associated with the selected mailbox
+ and returns the server to the authenticated state.
+ This command performs the same actions as CLOSE, except
+ that no messages are permanently removed from the currently
+ selected mailbox.
+
+ (typ, [data]) = <instance>.unselect()
+ """
+ try:
+ typ, data = self._simple_command('UNSELECT')
+ finally:
+ self.state = 'AUTH'
+ return typ, data
+
+
def xatom(self, name, *args):
"""Allow simple extension commands
notified by server in CAPABILITY response.