Re: Problem with imaplib (weird result if mailbox contains a %)




Antoon Pardon wrote:
This little program gives IMO a strange result.

import imaplib

user = "cpapen"

cyr = imaplib.IMAP4("imap.vub.ac.be")
cyr.login("cyrus", "cOn-A1r")
rc, lst = cyr.list('""', "user/%s/*" % user)
for el in lst:
print "%r" % (el,)

And the result is:

'(\\HasNoChildren) "/" "user/cpapen/Out"'
'(\\HasNoChildren) "/" "user/cpapen/Punten"'
'(\\HasNoChildren) "/" "user/cpapen/Spam"'
'(\\HasNoChildren) "/" "user/cpapen/agoog to be"'
'(\\HasNoChildren) "/" "user/cpapen/artistiek &- kunst"'
'(\\HasNoChildren) "/" "user/cpapen/copains et copinnes =x="'
'(\\HasNoChildren) "/" "user/cpapen/cp &- writing"'
'(\\HasNoChildren) "/" "user/cpapen/examen"'
'(\\HasNoChildren) "/" "user/cpapen/important info (pass)"'
'(\\HasNoChildren) "/" "user/cpapen/lesmateriaal"'
'(\\HasNoChildren) "/" "user/cpapen/love &- flesh for fantasy"'
'(\\HasNoChildren) "/" "user/cpapen/media"'
'(\\HasNoChildren) "/" "user/cpapen/music &- beats"'
('(\\HasNoChildren) "/" {25}', 'user/cpapen/newsletters %')
''
'(\\HasNoChildren) "/" "user/cpapen/organisatie &- structuur"'
'(\\HasNoChildren) "/" "user/cpapen/sociale wetenschappen"'
'(\\HasNoChildren) "/" "user/cpapen/the closest ones to me [x]"'
'(\\HasNoChildren) "/" "user/cpapen/vubrations"'
'(\\HasNoChildren) "/" "user/cpapen/wm2addressbook"'
'(\\HasNoChildren) "/" "user/cpapen/wm2prefs"'
'(\\HasNoChildren) "/" "user/cpapen/wm2signature"'


What I have a problem with is the 14th and 15th line.
All other entries are strings but the 14th is a tuple.
and the 15th is an empty string. As far as I can tell
every time a "%" is in the mailbox name I get this kind of
result.

I'm using python 2.3.3 and the imap sytem is Cyrus.

Can someone explain what is going one?

Is this a bug?

Empty string seems to be a bug. But tuple is by design, read the docs
and imap rfc. The protocol is convoluted in the first place, and so is
python interface.

If it is, is it fixed in later versions?

Why don't you try to pull imaplib.py from later versions? I don't think
it changed that much so it should be compatible with python 2.3

Whether or not it is a bug, can I rely on the mailbox
being the last item in the tuple in these cases?

Yes (at least for list command)

-- Leo

.



Relevant Pages

  • Re: OpenSource documentation problems
    ... a bug report that says more than "this doc is no good". ... important to report documentation bugs as program bugs. ... With Python the docs seem like much more of an afterthought. ...
    (comp.lang.python)
  • Weekly Python Patch/Bug Summary
    ... Patch / Bug Summary ... Fix various x86_64 build issues ... http://python.org/sf/1038388 closed by rhettinger ... New patch for Python 2.3 spec file. ...
    (comp.lang.python)
  • Re: Indentation and optional delimiters
    ... Probably many years ago a language like Python was too much ... But there's a need for higher level computer languages. ... Today Ruby is a bit higher-level than Python (despite being rather ... So it's a type bug. ...
    (comp.lang.python)
  • Re: Social problems of Python doc [was Re: Python docs disappointing]
    ... complaints to voice or improvements to suggest to the Python docs, ... Unless somebody raises a report in the bug tracker, ... Bug reports with patches are even more valuable, ...
    (comp.lang.python)
  • ANN: wxPython 2.6.0.1
    ... I'm pleased to announce the 2.6.0.1 release of wxPython, ... consists mostly of bug fixes made since the 2.6.0.0 release a month ... wxPython is a GUI toolkit for the Python programming language. ... in case there is more than one adjustment for a window in a single DeferWindowPos set, then the pending values can be used for defaults instead of current values. ...
    (comp.lang.python)