I comment out the {{{except ImportError as e:}}} in order to get a proper
stacktrace on where my code crashed.
So for example models.py imports from util.py that actually does not exist
i get error {{{ImportError: Could not import settings
'sharehoods.settings' (Is it on sys.path? Is there an import error in the
settings file?): No module named util}}}. Because this is not clear what
happened in the source code, i uncomment the exception catch in the source
code and then i get the real stacktrace where the import error happened in
my code so i know how to fix it. I'm not sure why the exception is
silenced and re-raised but i personally always have it commented out on my
pc so i thought i should mention.
--
Ticket URL: <https://code.djangoproject.com/ticket/23495>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Uncategorized => Core (Other)
* needs_tests: => 0
* easy: 1 => 0
* needs_docs: => 0
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Good intentions that do more harm than good. This happens often in Django!
How could be preserve the tip without destroying the stack trace? Just
print it and then `raise`?
--
Ticket URL: <https://code.djangoproject.com/ticket/23495#comment:1>
Comment (by carljm):
If we just print and then `raise`, the printed tip would likely be driven
right off the screen by the stacktrace and never seen.
Frankly I don't see that particular tip as providing much value over the
original `ImportError` itself.
--
Ticket URL: <https://code.djangoproject.com/ticket/23495#comment:2>
Comment (by aaugustin):
This seems to date back to r105 (don't miss r106).
The error message was improved a bit in [9a524e3c].
I think Jacob won't mind if we drop the try/except.
--
Ticket URL: <https://code.djangoproject.com/ticket/23495#comment:3>
* has_patch: 0 => 1
* version: 1.6 => master
Comment:
https://github.com/django/django/pull/3229
--
Ticket URL: <https://code.djangoproject.com/ticket/23495#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/23495#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"fc2b8ddcc8a0d68dcd333a77314c816469ba96af"]:
{{{
#!CommitTicketReference repository=""
revision="fc2b8ddcc8a0d68dcd333a77314c816469ba96af"
Fixed #23495 -- Stopped swallowing real settings import error
Thanks papaloizouc for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23495#comment:6>