Skip to content

Commit c6964fe

Browse files
committed
Modernize the CSRF migration helper.
Thanks Lennart Regebro for spotting that code.
1 parent 9c487b5 commit c6964fe

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

extras/csrf_migration_helper.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_template_dirs():
143143
"""
144144
from django.conf import settings
145145
dirs = set()
146-
if ('django.template.loaders.filesystem.load_template_source' in settings.TEMPLATE_LOADERS
146+
if ('django.template.loaders.filesystem.load_template_source' in settings.TEMPLATE_LOADERS
147147
or 'django.template.loaders.filesystem.Loader' in settings.TEMPLATE_LOADERS):
148148
dirs.update(map(unicode, settings.TEMPLATE_DIRS))
149149

@@ -281,12 +281,10 @@ def search_python_list(python_code, template_names):
281281
Returns a list of tuples, each one being:
282282
(filename, line number)
283283
"""
284-
retval = []
284+
retval = set()
285285
for tn in template_names:
286-
retval.extend(search_python(python_code, tn))
287-
retval = list(set(retval))
288-
retval.sort()
289-
return retval
286+
retval.update(search_python(python_code, tn))
287+
return sorted(retval)
290288

291289
def search_python(python_code, template_name):
292290
"""

0 commit comments

Comments
 (0)