gpt4 book ai didi

python:如何捕获 imaplib.abort?

转载 作者:行者123 更新时间:2023-12-02 20:06:13 27 4
gpt4 key购买 nike

这是我程序的相关部分:

    import imaplib
...
try:
M.expunge()
M.close()
M.logout()
except imaplib.abort as e:
print("IMAP abort")

这是错误信息:

Traceback (most recent call last):
File "/home/xxx/anaconda3/lib/python3.6/imaplib.py", line 1014, in _command_complete
typ, data = self._get_tagged_response(tag)
File "/home/xxx/anaconda3/lib/python3.6/imaplib.py", line 1126, in _get_tagged_response
self._check_bye()
File "/home/xxx/anaconda3/lib/python3.6/imaplib.py", line 929, in _check_bye
raise self.abort(bye[-1].decode(self._encoding, 'replace'))
imaplib.abort: IMAP session state is inconsistent, please relogin.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "mailstats/autoresponder.py", line 224, in <module>
M.close()
File "/home/xxx/anaconda3/lib/python3.6/imaplib.py", line 456, in close
typ, dat = self._simple_command('CLOSE')
File "/home/xxx/anaconda3/lib/python3.6/imaplib.py", line 1191, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/home/xxx/anaconda3/lib/python3.6/imaplib.py", line 1016, in _command_complete
raise self.abort('command: %s => %s' % (name, val))
imaplib.abort: command: CLOSE => IMAP session state is inconsistent, please relogin.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "mailstats/autoresponder.py", line 226, in <module>
except imaplib.abort as e:
AttributeError: module 'imaplib' has no attribute 'abort'

因此,如果 imaplib 没有名为 abort 的属性,那么 _check_bye 的第 929 行如何引发 self.abort()

我如何捕捉它?

最佳答案

imaplib.abort”行具有误导性。实际上,你需要 catch imaplib.IMAP4.abort .

关于python:如何捕获 imaplib.abort?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54601622/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com