[Python-checkins] CVS: python/dist/src/Lib imaplib.py,1.14,1.15
Guido van Rossum
guido@cnri.reston.va.us
Thu, 17 Feb 2000 12:12:42 -0500 (EST)
Update of /projects/cvsroot/python/dist/src/Lib
In directory eric:/projects/python/develop/guido/src/Lib
Modified Files:
imaplib.py
Log Message:
Patches by Piers Lauder.
Reasons for patches:
1st patch (15,21):
version change
2nd patch (66,72):
This is a patch I found in a Zope product release (quite by accident!).
It relaxes the conditions for matching a literal. I've looked over the
logic, and tested it, and it seems sensible.
3rd patch (117,123):
It appears the quoting matcher was too general, and that the IMAP4
protocol requires characters like ':' in commands to be unquoted.
(This is the patch already sent to Guido.)
4th patch (699,705):
Spelling correction in comment.
5th patch (753,761):
Another patch from the Zope product. It seems that some IMAP4 servers
produce unexpected responses in the middle of valid command/response
sequences. This patch ignores the unexpected responses in this
situation. (How I wish users would send me bug reports with examples!).
last 2 patches: (1015,1028) (1038,1044):
Minor improvements to test code.
Index: imaplib.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/imaplib.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** imaplib.py 1999/12/13 23:27:45 1.14
--- imaplib.py 2000/02/17 17:12:39 1.15
***************
*** 16,20 ****
"""
! __version__ = "2.16"
import binascii, re, socket, string, time, random, sys
--- 16,20 ----
"""
! __version__ = "2.30"
import binascii, re, socket, string, time, random, sys
***************
*** 67,71 ****
r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
r'"')
! Literal = re.compile(r'(?P<data>.*) {(?P<size>\d+)}$')
Response_code = re.compile(r'\[(?P<type>[A-Z-]+)( (?P<data>[^\]]*))?\]')
Untagged_response = re.compile(r'\* (?P<type>[A-Z-]+)( (?P<data>.*))?')
--- 67,71 ----
r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
r'"')
! Literal = re.compile(r'.*{(?P<size>\d+)}$')
Response_code = re.compile(r'\[(?P<type>[A-Z-]+)( (?P<data>[^\]]*))?\]')
Untagged_response = re.compile(r'\* (?P<type>[A-Z-]+)( (?P<data>.*))?')
***************
*** 118,122 ****
class readonly(abort): pass # Mailbox status changed to READ-ONLY
! mustquote = re.compile(r'\W') # Match any non-alphanumeric character
def __init__(self, host = '', port = IMAP4_PORT):
--- 118,122 ----
class readonly(abort): pass # Mailbox status changed to READ-ONLY
! mustquote = re.compile(r"[^\w!#$%&'*+,.:;<=>?^`|~-]")
def __init__(self, host = '', port = IMAP4_PORT):
***************
*** 700,704 ****
if self.mo is None:
! # Only other possibility is '+' (continuation) rsponse...
if self._match(Continuation, resp):
--- 700,704 ----
if self.mo is None:
! # Only other possibility is '+' (continuation) response...
if self._match(Continuation, resp):
***************
*** 754,760 ****
del self.tagged_commands[tag]
return result
- self._get_response()
def _get_line(self):
--- 754,772 ----
del self.tagged_commands[tag]
return result
+ # Some have reported "unexpected response" exceptions.
+ # (Isn't this non-IMAP4-compliant behaviour?
+ # Please mail me details printed below!)
+ # Anyway, ignore them here.
+ try:
+ self._get_response()
+ except self.abort, val:
+ if __debug__:
+ if self.debug >= 1:
+ _mesg('abort exception ignored: %s' % val)
+ print_log()
+
+
def _get_line(self):
***************
*** 1016,1021 ****
USER = getpass.getuser()
! PASSWD = getpass.getpass("IMAP password for %s: " % (host or "localhost"))
test_seq1 = (
('login', (USER, PASSWD)),
--- 1028,1034 ----
USER = getpass.getuser()
! PASSWD = getpass.getpass("IMAP password for %s on %s" % (USER, host or "localhost"))
+ test_mesg = 'From: %s@localhost\nSubject: IMAP4 test\n\ndata...\n' % USER
test_seq1 = (
('login', (USER, PASSWD)),
***************
*** 1023,1027 ****
('rename', ('/tmp/xxx 1', '/tmp/yyy')),
('CREATE', ('/tmp/yyz 2',)),
! ('append', ('/tmp/yyz 2', None, None, 'From: anon@x.y.z\n\ndata...')),
('list', ('/tmp', 'yy*')),
('select', ('/tmp/yyz 2',)),
--- 1036,1040 ----
('rename', ('/tmp/xxx 1', '/tmp/yyy')),
('CREATE', ('/tmp/yyz 2',)),
! ('append', ('/tmp/yyz 2', None, None, test_mesg)),
('list', ('/tmp', 'yy*')),
('select', ('/tmp/yyz 2',)),
***************
*** 1039,1043 ****
('uid', ('SEARCH', 'ALL')),
('response', ('EXISTS',)),
! ('append', (None, None, None, 'From: anon@x.y.z\n\ndata...')),
('recent', ()),
('logout', ()),
--- 1052,1056 ----
('uid', ('SEARCH', 'ALL')),
('response', ('EXISTS',)),
! ('append', (None, None, None, test_mesg)),
('recent', ()),
('logout', ()),