Code

Opened 7 years ago

Closed 6 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:

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

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by guido@…

Patch for django/views/debug.py

comment:1 Changed 7 years ago by guido@…

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 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 7 years ago by guido@…

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

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

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:5 Changed 6 years ago by mtredinnick

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

(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 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.