Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13404 closed (fixed)

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

Reported by: wkornewald 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 wkornewald 4 years ago.
possible fix? not sure if it's the best solution
t13404.diff (1.3 KB) - added by russellm 4 years ago.
Possible fix for submodule detection

Download all attachments as: .zip

Change History (9)

Changed 4 years ago by wkornewald

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

comment:1 Changed 4 years ago by russellm

  • Component changed from Uncategorized to Core framework
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 4 years ago by russellm

Possible fix for submodule detection

comment:2 Changed 4 years ago by russellm

@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 4 years ago by wkornewald

It works. Thanks for the patch, Russell!

comment:4 Changed 4 years ago by Alex

  • Has patch set
  • Triage Stage changed from Accepted to Ready for checkin

Marking as RFC.

comment:5 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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 4 years ago by russellm

(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 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.