[Django] #23495: ImportError silenced

7 views
Skip to first unread message

Django

unread,
Sep 16, 2014, 1:01:45 PM9/16/14
to django-...@googlegroups.com
#23495: ImportError silenced
--------------------------+------------------------------------------------
Reporter: | Owner: nobody
papaloizouc | Status: new
Type: | Version: 1.6
Uncategorized | Keywords: exceptions, import, conf, settings
Component: | Has patch: 0
Uncategorized | UI/UX: 0
Severity: Normal |
Triage Stage: |
Unreviewed |
Easy pickings: 1 |
--------------------------+------------------------------------------------
Hi sometimes i get import errors silenced by {{{django/conf/__init__.py}}}
source code link
[https://github.com/django/django/blob/885ff6845e54511022677c1f28b84ddd4f2165dd/django/conf/__init__.py#L94]

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.

Django

unread,
Sep 16, 2014, 1:09:14 PM9/16/14
to django-...@googlegroups.com
#23495: ImportError silenced
-------------------------------------+-------------------------------------
Reporter: papaloizouc | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Core (Other) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: exceptions, import, | Needs documentation: 0
conf, settings | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* 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>

Django

unread,
Sep 16, 2014, 4:20:27 PM9/16/14
to django-...@googlegroups.com
#23495: ImportError silenced
-------------------------------------+-------------------------------------
Reporter: papaloizouc | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Core (Other) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: exceptions, import, | Needs documentation: 0
conf, settings | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

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>

Django

unread,
Sep 16, 2014, 4:34:31 PM9/16/14
to django-...@googlegroups.com
#23495: ImportError silenced
-------------------------------------+-------------------------------------
Reporter: papaloizouc | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Core (Other) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: exceptions, import, | Needs documentation: 0
conf, settings | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

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>

Django

unread,
Sep 17, 2014, 4:45:48 AM9/17/14
to django-...@googlegroups.com
#23495: ImportError silenced
-------------------------------------+-------------------------------------
Reporter: papaloizouc | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master

Component: Core (Other) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: exceptions, import, | Needs documentation: 0
conf, settings | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0

Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by claudep):

* 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>

Django

unread,
Sep 17, 2014, 4:48:12 AM9/17/14
to django-...@googlegroups.com
#23495: ImportError silenced
-------------------------------------+-------------------------------------
Reporter: papaloizouc | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Core (Other) | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: exceptions, import, | checkin
conf, settings | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/23495#comment:5>

Django

unread,
Sep 17, 2014, 11:16:05 AM9/17/14
to django-...@googlegroups.com
#23495: ImportError silenced
-------------------------------------+-------------------------------------
Reporter: papaloizouc | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Core (Other) | Resolution: fixed

Severity: Normal | Triage Stage: Ready for
Keywords: exceptions, import, | checkin
conf, settings | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

* 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>

Reply all
Reply to author
Forward
0 new messages