Opened 6 years ago

Closed 6 years ago

Last modified 5 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: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 6 years ago.
possible fix? not sure if it's the best solution
t13404.diff (1.3 KB) - added by Russell Keith-Magee 6 years ago.
Possible fix for submodule detection

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by Waldemar Kornewald

Attachment: loader.diff added

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

comment:1 Changed 6 years ago by Russell Keith-Magee

Component: UncategorizedCore framework
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Changed 6 years ago by Russell Keith-Magee

Attachment: t13404.diff added

Possible fix for submodule detection

comment:2 Changed 6 years ago by Russell Keith-Magee

@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 Changed 6 years ago by Waldemar Kornewald

It works. Thanks for the patch, Russell!

comment:4 Changed 6 years ago by Alex Gaynor

Has patch: set
Triage Stage: AcceptedReady for checkin

Marking as RFC.

comment:5 Changed 6 years ago by Russell Keith-Magee

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 Changed 6 years ago by Russell Keith-Magee

(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 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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