From 5fd7306b7e87d4056291abdc9e8baad956c01e1b Mon Sep 17 00:00:00 2001 From: Dirk Eschler Date: Sat, 6 Mar 2010 01:40:26 +0000 Subject: [PATCH] Added workaround for swallowed ImportErrors by printing a traceback explicitly. Mostly resolves issue 17. --- modeltranslation/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modeltranslation/models.py b/modeltranslation/models.py index 08b7850..ea37d44 100644 --- a/modeltranslation/models.py +++ b/modeltranslation/models.py @@ -15,8 +15,14 @@ from modeltranslation.translator import translator try: import translation except ImportError: - sys.stderr.write("modeltranslation: Error can't find the file " \ - "'translation.py' in your project root.\n") + sys.stderr.write("modeltranslation: Can't import the file 'translation.py'" + "from your project root.\n(If the file does indeed exist," + "it's causing an ImportError somehow.)\n") + # For some reason ImportErrors raised in translation.py or in modules + # that are included from there become swallowed. Work around this problem + # by printing the traceback explicitly. + import traceback + traceback.print_exc() sys.exit(1) # After importing all translation modules, all translation classes are