#15662 closed Bug (fixed)
module_has_submodule incorrectly uses the Importer Protocol
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Other) | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | lrekucki@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
django.utils.module_loading.module_has_submodule has the code:
for finder in sys.meta_path: if finder.find_module(name): return True
where name
is the absolute path to the module that should be imported. However PEP302 that defines the Importer Protocol says that a second argument must be supplied if the module isn't directly on sys.path
.
Thus, the code should be:
for finder in sys.meta_path: if finder.find_module(name, package): return True
I came across this problem with using Attest, Django, and loading a template tag that had the same name as a package on my PATH.
Attachments (3)
Change History (11)
Changed 12 years ago by
Attachment: | module_loading.py.patch added |
---|
comment:1 Changed 12 years ago by
Cc: | lrekucki@… added |
---|
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
Component: | Uncategorized → Core framework |
---|
comment:4 Changed 12 years ago by
Type: | → Bug |
---|
comment:5 Changed 12 years ago by
Severity: | → Normal |
---|
comment:6 Changed 12 years ago by
milestone: | 1.3 |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
Note: See
TracTickets for help on using
tickets.
a) There's a typo in the patch, b) could use tests, c) <redacted> :)