Opened 17 years ago

Closed 17 years ago

#6359 closed (fixed)

_get_lines_from_file() assumes loader.get_source() always exists

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

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

django/views/debug.py 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@… 17 years ago.
Patch for django/views/debug.py

Download all attachments as: .zip

Change History (6)

by guido@…, 17 years ago

Attachment: debug.diff added

Patch for django/views/debug.py

comment:1 by guido@…, 17 years ago

Has patch: set

comment:2 by Collin Grady <cgrady@…>, 17 years ago

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 by guido@…, 17 years ago

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

comment:4 by Simon Greenhill <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:5 by Malcolm Tredinnick, 17 years ago

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