#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)
by , 14 years ago
Attachment: | module_loading.py.patch added |
---|
comment:1 by , 14 years ago
Cc: | added |
---|
comment:2 by , 14 years ago
comment:3 by , 14 years ago
Component: | Uncategorized → Core framework |
---|
comment:4 by , 14 years ago
Type: | → Bug |
---|
comment:5 by , 14 years ago
Severity: | → Normal |
---|
comment:6 by , 14 years ago
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> :)