Django

Code

Ticket #6359 (closed: fixed)

Opened 1 year ago

Last modified 10 months ago

_get_lines_from_file() assumes loader.get_source() always exists

Reported by: guido@python.org Assigned to: nobody
Milestone: Component: Uncategorized
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

debug.diff (0.6 kB) - added by guido@python.org on 01/10/08 16:57:56.
Patch for django/views/debug.py

Change History

01/10/08 16:57:56 changed by guido@python.org

  • attachment debug.diff added.

Patch for django/views/debug.py

01/10/08 16:58:29 changed by guido@python.org

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

01/10/08 20:50:32 changed by Collin Grady <cgrady@the-magi.us>

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 :)

01/10/08 21:43:11 changed by guido@python.org

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

01/12/08 04:45:02 changed by Simon Greenhill <dev@simon.net.nz>

  • stage changed from Unreviewed to Ready for checkin.

02/02/08 20:11:58 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #6359 (_get_lines_from_file() assumes loader.get_source() always exists)




Change Properties
Action