Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(27)

Side by Side Diff: Lib/imaplib.py

Issue 4972: context managerment support in imaplib, smtplib, ftplib
Patch Set: Created 5 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/whatsnew/3.5.rst ('k') | Lib/test/test_imaplib.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """IMAP4 client. 1 """IMAP4 client.
2 2
3 Based on RFC 2060. 3 Based on RFC 2060.
4 4
5 Public class: IMAP4 5 Public class: IMAP4
6 Public variable: Debug 6 Public variable: Debug
7 Public functions: Internaldate2tuple 7 Public functions: Internaldate2tuple
8 Int2AP 8 Int2AP
9 ParseFlags 9 ParseFlags
10 Time2Internaldate 10 Time2Internaldate
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 raise self.error('server not IMAP4 compliant') 232 raise self.error('server not IMAP4 compliant')
233 233
234 234
235 def __getattr__(self, attr): 235 def __getattr__(self, attr):
236 # Allow UPPERCASE variants of IMAP4 command methods. 236 # Allow UPPERCASE variants of IMAP4 command methods.
237 if attr in Commands: 237 if attr in Commands:
238 return getattr(self, attr.lower()) 238 return getattr(self, attr.lower())
239 raise AttributeError("Unknown IMAP4 command: '%s'" % attr) 239 raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
240 240
241 def __enter__(self):
242 return self
243
244 def __exit__(self, *args):
245 try:
246 self.logout()
247 except OSError:
248 pass
241 249
242 250
243 # Overridable methods 251 # Overridable methods
244 252
245 253
246 def _create_socket(self): 254 def _create_socket(self):
247 return socket.create_connection((self.host, self.port)) 255 return socket.create_connection((self.host, self.port))
248 256
249 def open(self, host = '', port = IMAP4_PORT): 257 def open(self, host = '', port = IMAP4_PORT):
250 """Setup connection to remote server on "host:port" 258 """Setup connection to remote server on "host:port"
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 except: 1548 except:
1541 print('\nTests failed.') 1549 print('\nTests failed.')
1542 1550
1543 if not Debug: 1551 if not Debug:
1544 print(''' 1552 print('''
1545 If you would like to see debugging output, 1553 If you would like to see debugging output,
1546 try: %s -d5 1554 try: %s -d5
1547 ''' % sys.argv[0]) 1555 ''' % sys.argv[0])
1548 1556
1549 raise 1557 raise
OLDNEW
« no previous file with comments | « Doc/whatsnew/3.5.rst ('k') | Lib/test/test_imaplib.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+