From fac8dbff010195d53f38c875a5c4be8c6a1af63e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 2 Nov 2019 13:12:45 +0100 Subject: [PATCH] Undefined name: e in data_migration_run.py The current code raises a NameError which is never logged. [flake8](http://flake8.pycqa.org) testing of https://github.com/frappe/frappe on Python 3.8.0 $ __flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics__ ``` ./frappe/data_migration/doctype/data_migration_run/data_migration_run.py:417:63: F821 undefined name 'e' self.update_log('pull_failed', {migration_id_value: cstr(e)}) ^ ./frappe/patches/v5_0/fix_email_alert.py:12:37: F821 undefined name 'email_alert' notification.days_in_advance = -email_alert.days_in_advance ^ 2 F821 undefined name 'e' 2 ``` __E901,E999,F821,F822,F823__ are the "_showstopper_" [flake8](http://flake8.pycqa.org) issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety. * F821: undefined name `name` * F822: undefined name `name` in `__all__` * F823: local variable name referenced before assignment * E901: SyntaxError or IndentationError * E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree --- .../doctype/data_migration_run/data_migration_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/data_migration/doctype/data_migration_run/data_migration_run.py b/frappe/data_migration/doctype/data_migration_run/data_migration_run.py index 93c0d8254d..b2ce4606f8 100644 --- a/frappe/data_migration/doctype/data_migration_run/data_migration_run.py +++ b/frappe/data_migration/doctype/data_migration_run/data_migration_run.py @@ -412,7 +412,7 @@ class DataMigrationRun(Document): self.update_log('pull_update', 1) # post process doc after success self.post_process_doc(remote_doc=d, local_doc=local_doc) - except Exception: + except Exception as e: # failed, append to log self.update_log('pull_failed', {migration_id_value: cstr(e)})