From 4307ad6efca327e9ad1e00a9145a62fcc3d6ec7f Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 11 Jan 2022 11:50:27 +0000 Subject: [PATCH] [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) --- addons/fetchmail/models/fetchmail.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/fetchmail/models/fetchmail.py b/addons/fetchmail/models/fetchmail.py index 56cb59c043c..90b99ede161 100644 --- a/addons/fetchmail/models/fetchmail.py +++ b/addons/fetchmail/models/fetchmail.py @@ -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()