Changes between Version 2 and Version 3 of Ticket #28241


Ignore:
Timestamp:
May 26, 2017, 5:57:04 AM (7 years ago)
Author:
Tim Graham
Comment:

I don't think the module_name argument of module_has_submodule() is expected to be a dotted path. For example, this test (incorrectly, as far as I see) passes on Python 2:

  • tests/utils_tests/test_module_loading.py

    diff --git a/tests/utils_tests/test_module_loading.py b/tests/utils_tests/test_module_loading.py
    index 2a524a2..70047b2 100644
    a b class DefaultLoader(unittest.TestCase):  
    2626        test_no_submodule = import_module(
    2727            'utils_tests.test_no_submodule')
    2828
     29        self.assertTrue(module_has_submodule(test_module, 'invalid.good_module'))
     30
    2931        # An importable child
    3032        self.assertTrue(module_has_submodule(test_module, 'good_module'))
    3133        mod = import_module('utils_tests.test_module.good_module')

Is Django making any calls like that or is this function used like this outside of Django?

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28241

    • Property Summary module_has_submodule raises exceptions in Python 3module_has_submodule() doesn't work correctly if the module_name argument is a dotted path
    • Property Easy pickings unset
  • Ticket #28241 – Description

    v2 v3  
    11Hello,
    22
    3 Porting a django project from python 2.7 to 3.6, I noticed an issue with ``utils.module_loading.module_has_submodule``. At some stage my project makes use of ``autodiscover_modules('module.submodule')`` to try and discover modules that are nested in my app.
     3Porting a django project from python 2.7 to 3.6, I noticed an issue with `utils.module_loading.module_has_submodule`. At some stage my project makes use of `autodiscover_modules('module.submodule')` to try and discover modules that are nested in my app.
    44
    5 I'm using django 1.11.1, but this bug probably also affects 1.8 as the code of ``module_has_submodule`` is the same.
     5I'm using django 1.11.1, but this bug probably also affects 1.8 as the code of `module_has_submodule` is the same.
    66
    77So here we go, with python 2.7 we have the expected behavior (taking contenttypes as an example app):
     
    5050
    5151What are your thoughts ?
    52 
    53 
Back to Top