This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 'abort' object is not callable
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Apple Grew, doerwalter, ezio.melotti, r.david.murray
Priority: normal Keywords:

Created on 2014-07-12 20:26 by Apple Grew, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (8)
msg222879 - (view) Author: Apple Grew (Apple Grew) Date: 2014-07-12 20:26
I am sometimes getting the following error from imaplib.

Traceback (most recent call last):
  File "client.py", line 105, in get_new_mail_uids
    result, data = retryableCall(lambda : mail.uid('search', None, "UNSEEN"), retries, delay) # search and return uids instead
  File "client.py", line 25, in retryableCall
    return f()
  File "client.py", line 105, in 
    result, data = retryableCall(lambda : mail.uid('search', None, "UNSEEN"), retries, delay) # search and return uids instead
  File "/usr/lib/python2.6/imaplib.py", line 753, in uid
    typ, dat = self._simple_command(name, command, *args)
  File "/usr/lib/python2.6/imaplib.py", line 1060, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python2.6/imaplib.py", line 893, in _command_complete
    self._check_bye()
  File "/usr/lib/python2.6/imaplib.py", line 808, in _check_bye
    raise self.abort(bye[-1])
TypeError: 'abort' object is not callable
msg222881 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-07-12 20:36
Do you assign anything to self.abort in your code?
Without further information we can't determine if this is a bug with impalib, I checked the code and I don't see anything that might change self.abort.
msg222884 - (view) Author: Apple Grew (Apple Grew) Date: 2014-07-12 20:58
That is the problem. I don't assign anything to that. I in fact grepped my
code for the word abort but could find none, except in the following code
block.

def retryableCall(f, retries, delay):
    while True:
        try:
            return f()
        except imaplib.IMAP4_SSL.abort, imaplib.IMAP4.abort:
            if retries > 0:
                retries -= 1
                try:
                    mail.shutdown()
                except Exception, e:
                    if verbose:
                        print 'Error in shutting down mail.', e
                        print e

                time.sleep(delay)
                open_connection(non_retryable=True)
            else:
                raise
        except imaplib.IMAP4_SSL.readonly, imaplib.IMAP4.readonly:
            if retries > 0:
                retries -= 1
                time.sleep(delay)
            else:
                raise
msg222885 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-07-12 21:14
In imaplib, abort is either raised or caught (in addition to be the defined once), so the error doesn't seem to be there.
I suggest you to try and print self.abort (and possibly its repr()/id() or similar informations) and try to determine if/when it gets changed and then try to find out what changed it to what.
msg222886 - (view) Author: Apple Grew (Apple Grew) Date: 2014-07-12 21:19
Yes, I actually doing - print '>>', self.abort, from _init_, and other methods I am invoking. However, that seems to print nothing! I don't know why. My codes which is using impalib is able to print stuffs.
msg223102 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2014-07-15 12:09
The problem seems to be in that line:

   except imaplib.IMAP4_SSL.abort, imaplib.IMAP4.abort:

This does *not* catch both exception classes, but catches only IMAP4_SSL.abort and stores the exception object in imaplib.IMAP4.abort.

What you want is:

   except (imaplib.IMAP4_SSL.abort, imaplib.IMAP4.abort):
msg223112 - (view) Author: Apple Grew (Apple Grew) Date: 2014-07-15 14:40
Oops. I totally missed this. Thanks for pointing this out. I would have never found this.
msg223113 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-07-15 14:53
That's why we made the syntax require the 'as' keyword in 3.x :)
History
Date User Action Args
2022-04-11 14:58:05adminsetgithub: 66167
2014-07-15 14:53:26r.david.murraysetnosy: + r.david.murray
messages: + msg223113

resolution: not a bug
stage: resolved
2014-07-15 14:40:20Apple Grewsetstatus: open -> closed

messages: + msg223112
2014-07-15 12:09:45doerwaltersetnosy: + doerwalter
messages: + msg223102
2014-07-12 21:19:30Apple Grewsetmessages: + msg222886
2014-07-12 21:14:25ezio.melottisetmessages: + msg222885
2014-07-12 20:58:06Apple Grewsetmessages: + msg222884
2014-07-12 20:36:48ezio.melottisettype: crash -> behavior

messages: + msg222881
nosy: + ezio.melotti
2014-07-12 20:26:53Apple Grewcreate