offlineimap3
offlineimap3 copied to clipboard
Comment about UID 0 in search
Hi,
I was checking this code, and I found a strange situation. The server returns [b'1 2 3...'], then we split it and we get ['1', '2', '3',...]. This value is stored in res_data
if ' ' in res_data[0] or res_data[0] == '':
res_data = res_data[0].split()
Then, we check if the UID 0 is included:
# Some servers are broken.
if 0 in res_data:
self.ui.warn("server returned UID with 0; ignoring.")
res_data.remove(0)
We are checking an int in a str lists. So this code is not doing anything. It should be:
# Some servers are broken.
if '0' in res_data:
self.ui.warn("server returned UID with 0; ignoring.")
res_data.remove('0')
How is in Python 2? Probably we have the same issue.
To check this code, the easiest way is change this:
if maxsize is not None:
conditions.append("SMALLER %d" % maxsize)
- if len(conditions) >= 1:
+ if len(conditions) >= 0:
# Build SEARCH command.
search_cond = "(%s)" % ' '.join(conditions)
search_result = search(search_cond)
Regards, kix