[FIX] fetchmail: pop server without message no error

In 72cd8d076 there was an improvement for removing infinite loop in POP
mail server, but if there was no message to fetch, you can get an error:

UnboundLocalError: local variable 'num' referenced  before assignment

because `num` is not set when logging stats of fetching mails.

`num` should be set to 0 by default, we don't want to have it unset or
use a value from a previous loop.

opw-2724216

closes odoo/odoo#82582

X-original-commit: 7b3b623cf3359ac1eea537177f7f963e81403a01
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Nicolas Lempereur
2022-01-12 07:44:06 +00:00
parent 11e17dc11b
commit 4307ad6efc
+1
View File
@@ -192,6 +192,7 @@ odoo_mailgate: "|/path/to/odoo-mailgate.py --host=localhost -u %(uid)d -p PASSWO
try:
while True:
failed_in_loop = 0
num = 0
pop_server = server.connect()
(num_messages, total_size) = pop_server.stat()
pop_server.list()