Skip to content

Commit 05d5774

Browse files
committed
Use fix for Django #25848 to get 1.9 working
1 parent b27a472 commit 05d5774

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

django_coverage_plugin/plugin.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ def check_debug():
5252
)
5353

5454
if django.VERSION >= (1, 9):
55-
# The filename used to be self.source[0].name. In more modern Djangos,
56-
# it's context.template.origin.
55+
# Since we are grabbing at internal details, we have to adapt as they
56+
# change over versions.
5757
def filename_for_frame(frame):
5858
try:
59-
return frame.f_locals["context"].template.origin.name
59+
return frame.f_locals["self"].origin.name
6060
except (KeyError, AttributeError):
6161
return None
6262

6363
def position_for_node(node):
64-
return node.token.position
64+
try:
65+
return node.token.position
66+
except AttributeError:
67+
return None
6568

6669
def position_for_token(token):
6770
return token.position

0 commit comments

Comments
 (0)