Opened 10 years ago

Closed 10 years ago

#6359 closed (fixed)

_get_lines_from_file() assumes loader.get_source() always exists

Reported by: guido@… Owned by: nobody
Component: Uncategorized 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:


PEP 302 says that loaders may *optionally* implement get_source(). It also says that it may return None.

django/views/ line 196 assumes that it always exists and never returns None.

Here's a patch that fixes this.

Attachments (1)

debug.diff (640 bytes) - added by guido@… 10 years ago.
Patch for django/views/

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by guido@…

Attachment: debug.diff added

Patch for django/views/

comment:1 Changed 10 years ago by guido@…

Has patch: set

comment:2 Changed 10 years ago by Collin Grady <cgrady@…>

Is the loader is not None bit needed since you're adding hasattr()?

hasattr(None, "get_source") is False, so that seems to cover both cases on its own :)

comment:3 Changed 10 years ago by guido@…

True, but it does become more obscure that way IMO. Anyway, your choice.

comment:4 Changed 10 years ago by Simon Greenhill <dev@…>

Triage Stage: UnreviewedReady for checkin

comment:5 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [7063]) Fixed #6359 -- Fixed an oversight in the debug output: template loaders need not have a get_source() method. Thanks, Guido van Rossum.

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