From 7374f4cefdfd46cd55c63358569a60ff5b59a053 Mon Sep 17 00:00:00 2001 From: Safe Hammad Date: Mon, 12 Jan 2015 17:41:06 +0000 Subject: [PATCH] Fix check for missing import_helper module in dumpscript (Python 3.3+). Since Python 3.3 the ImportError message has been changed from "No module named foo" to "No module named 'foo'" (note the quotes). This broke the check for a missing import_helper module when running a script generated by the dumpscript management command. --- django_extensions/management/commands/dumpscript.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django_extensions/management/commands/dumpscript.py b/django_extensions/management/commands/dumpscript.py index 5d4181789..fe84159a2 100644 --- a/django_extensions/management/commands/dumpscript.py +++ b/django_extensions/management/commands/dumpscript.py @@ -640,7 +640,8 @@ def save_or_locate(self, the_obj): # has no knowlodge of this class importer = type("DynamicImportHelper", (import_helper.ImportHelper, BasicImportHelper ) , {} )() except ImportError as e: - if str(e) == "No module named import_helper": + # From Python 3.3 we can check e.name - string match is for backward compatibility. + if 'import_helper' in str(e): importer = BasicImportHelper() else: raise