Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#13404 closed (fixed)

django.utils.module_loading fails if loader has no prefix attribute

Reported by: Waldemar Kornewald Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords:
Cc: 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

In module_has_submodule() you check if a module is loaded from an egg, but if the module loader is a custom loader it might not have a prefix attribute (which is the case with App Engine's HardenedModulesHook, for example). Currently, Django raises an exception and is unusable on App Engine.

Attachments (2)

loader.diff (598 bytes ) - added by Waldemar Kornewald 15 years ago.
possible fix? not sure if it's the best solution
t13404.diff (1.3 KB ) - added by Russell Keith-Magee 15 years ago.
Possible fix for submodule detection

Download all attachments as: .zip

Change History (9)

by Waldemar Kornewald, 15 years ago

Attachment: loader.diff added

possible fix? not sure if it's the best solution

comment:1 by Russell Keith-Magee, 15 years ago

Component: UncategorizedCore framework
Triage Stage: UnreviewedAccepted

by Russell Keith-Magee, 15 years ago

Attachment: t13404.diff added

Possible fix for submodule detection

comment:2 by Russell Keith-Magee, 15 years ago

@wkornewald - Just ignoring the branch if prefix doesn't exist doesn't seem quite right. The branch (in fact, the entire method) exists to ensure that we can tell the difference between import errors caused by a missing module, and import errors thrown by an existent, but buggy module. If you don't care about error reporting, you can skip the whole 'if loader' path for eggs, too -- you just don't get helpful error messages.

I've uploaded an alternate patch that avoids the need to use prefix. Can you try it out and see if it works on AppEngine?

comment:3 by Waldemar Kornewald, 15 years ago

It works. Thanks for the patch, Russell!

comment:4 by Alex Gaynor, 15 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

Marking as RFC.

comment:5 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: newclosed

(In [13023]) Fixed #13404 -- Reworked module_has_submodule() to allow it to work under AppEngine. Thanks to Waldemar Kornewald for the report and testing help.

comment:6 by Russell Keith-Magee, 15 years ago

(In [13024]) [1.1.X] Fixed #13404 -- Reworked module_has_submodule() to allow it to work under AppEngine. Thanks to Waldemar Kornewald for the report and testing help.

Backport of r13023 from trunk.

comment:7 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top