I returned to some old code (not that old - circa 6 months) and all of a sudden I'm getting a rather inexplicable error. What makes it particularly surprising is that this is not in my code - it's in the copy of the stdlib that goes with my Jython install, which I have not touched in any way (and which is local to my machine, so nobody else has touched it either).

To top it off the offending code looks completely innocuous to me. It's in standard imaplib.py, and it looks unproblematic. The error I get is:

  File "C:\jython2.5.3\Lib\imaplib.py", line 504, in login
    return login(user, password)
   NameError: global name 'login' is not defined

And the code is:

def login(self, user, password):
    """Identify client using plaintext password.

    (typ, [data]) = <instance>.login(user, password)

    NB: 'password' will be quoted.
    """
    typ, dat = self._simple_command('LOGIN', user, self._quote(password))
    if typ != 'OK':
        self.error(dat[-1])
        time.sleep(15)
        return login(user, password)
    self.state = 'AUTH'
    return typ, dat

That's just a vanilla recursion, yes?

Any thoughts on how to sherlock this? I'm pretty stumped.

有帮助吗?

解决方案 2

I finally found the underlying problem. It turned out that somebody had changed the authentication policy for the account, so that google was not allowing login even with correct credentials. I have not gone into detail as to why the name 'login' is undefined in this scenario, but I do know that setting up the correct access on our google account eliminated the problem.

其他提示

Instead of:

return login(user, password)

use:

return self.login(user, password)

(use method, not global function)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top