Revert "use .response() rather _get_untagged_response()"

Recently the internal function use of imaplib2's _get_untagged_response()
was switched to use the public documented .response() function (which
should return the same data). However within a few fays we received reports
that both uses of a) the UIDVALIDITY fetching and b) the APPENDUID fetching
returned [None] as data although the IMAP log definitely shows that data
was returned. Revert to using the undocumented internal imaplib2 function,
that seemed to have worked without problems. This needs to be taken up to
the imaplib2 developer.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2012-01-09 09:51:43 +01:00
parent 81f194adca
commit 3284e010ff

View File

@ -70,9 +70,12 @@ class IMAPFolder(BaseFolder):
try:
# SELECT receives UIDVALIDITY response
self.selectro(imapobj)
typ, uidval = imapobj.response('UIDVALIDITY')
# note: we would want to use .response() here but that
# often seems to return [None], even though we have
# data. TODO
uidval = imapobj._get_untagged_response('UIDVALIDITY')
assert uidval != [None], "response('UIDVALIDITY') returned [None]!"
return long(uidval[0])
return long(uidval[-1])
finally:
self.imapserver.releaseconnection(imapobj)
@ -567,8 +570,11 @@ class IMAPFolder(BaseFolder):
if use_uidplus or imapobj._get_untagged_response('APPENDUID', True):
# get new UID from the APPENDUID response, it could look
# like OK [APPENDUID 38505 3955] APPEND completed with
# 38505 bein folder UIDvalidity and 3955 the new UID
typ, resp = imapobj.response('APPENDUID')
# 38505 bein folder UIDvalidity and 3955 the new UID.
# note: we would want to use .response() here but that
# often seems to return [None], even though we have
# data. TODO
resp = imapobj._get_untagged_response('APPENDUID')
if resp == [None]:
self.ui.warn("Server supports UIDPLUS but got no APPENDUID "
"appending a message.")