#28913: If MIGRATIONS_MODULES has a missing top-level package, proper error 
message
is not displayed
-----------------------------------------+------------------------
               Reporter:  oTree-org      |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Uncategorized  |        Version:  1.11
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 The following code in django.db.migrations.writer doesn't handle the case
 where the top-level package doesn't exist. When existing_dirs only has one
 element left, it will be popped, so existing_dirs is empty. Then
 import_module() will be passed an empty string, which doesn't raise
 ImportError, but rather "ValueError: Empty module name". Because
 ValueError is not caught, the "raise ValueError" with the helpful error
 message is not displayed.

 {{{
         # In case of using MIGRATION_MODULES setting and the custom
 package
         # doesn't exist, create one, starting from an existing package
         existing_dirs, missing_dirs = migrations_package_name.split("."),
 []
         while existing_dirs:
             missing_dirs.insert(0, existing_dirs.pop(-1))
             try:
                 base_module = import_module(".".join(existing_dirs))
             except ImportError:
                 continue
             else:
                 try:
                     base_dir = module_dir(base_module)
                 except ValueError:
                     continue
                 else:
                     break
         else:
             raise ValueError(
                 "Could not locate an appropriate location to create "
                 "migrations package %s. Make sure the toplevel "
                 "package exists and can be imported." %
                 migrations_package_name)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28913>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.7fc4e9fa35ae811f732b5375f073e6d3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to