#22920: AppConfig.create swallows informative exceptions during import time
-------------------------------------+-------------------------------------
     Reporter:  bendavis78           |                    Owner:  aaugustin
         Type:  Bug                  |                   Status:  assigned
    Component:  Core (Other)         |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:  AppConfig app-       |             Triage Stage:  Accepted
  loading ImportError                |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

 * keywords:  AppConfig app loading ImportError => AppConfig app-loading
     ImportError
 * status:  new => assigned
 * severity:  Release blocker => Normal
 * owner:  nobody => aaugustin
 * stage:  Unreviewed => Accepted


Comment:

 I believe the issue is valid and we should address it.

 Can you confirm that the exception masking happens on Python 2 — due to
 the lack of exception chaining — in this section of the code?

 {{{
         except AttributeError:
             # Emulate the error that "from <mod_path> import <cls_name>"
             # would raise when <mod_path> exists but not <cls_name>, with
             # more context (Python just says "cannot import name ...").
             raise ImportError(
                 "cannot import name '%s' from '%s'" % (cls_name,
 mod_path))
 }}}

 I'm not very proud of that code and I'm not surprised someone came and
 flamed it ;-)

 ----

 If I read your patch correctly, at some point, you redo an import that you
 know will fail in order to obtain the correct traceback. Two questions:

 1 - Why wasn't it sufficient to use that trick in the piece of code I
 quoted above?
 2 - Isn't it going to be confusing on Python 3, because of the exception
 chaining ?

 I read your patch carefully but I found it hard to validate because it
 rewrites a section that is inherently difficult to test. Thanks for adding
 tests, though, that's very helpful in any case.

 ----

 I consider this a minor bug because it doesn't affect functionality, only
 error reporting on projets that don't work anyway. Did I miss the reason
 why you marked it as a blocker?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22920#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.9155dc4a1609a9096f35d70a9180f5e9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to